home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / trial / MonitorIT 5.2.06 / monitorit_fullsetup.exe / data1.cab / Js / AdministerComputersMain.js < prev    next >
Encoding:
Text File  |  2003-06-24  |  141.9 KB  |  4,016 lines

  1.  
  2. var CMode = ""; // Mode of Operation, New, Edit, Delete, Lookup
  3. var IMode = ""; // Initial Lookup mode
  4. var IModeFirstTimeServer = true;
  5. var IModeFirstTimeGroup = true;
  6. var CName = "*"; // Computer Name
  7. var OrigCName = "*"; // Origianl Computer Name
  8. var CGrpID = "*"; // Computer Group ID
  9. var CurSelectIdx = 0; // Index of currently selected Computer name in Combo 
  10. var CompDeleteID = null; // ID of Computer to Delete
  11. var ServicesCheckingStopped = false;
  12. var allGrpSelected = 0; // All Groups selected for Lookup
  13.  
  14. var bdH = 0;
  15. var byM = null;
  16. var borderSz = 2; // Thin Bord is 2pixels
  17. var Tid = null, CTid = null; // Timeout ID
  18.  
  19. var StopFlag = false; // abort Discovery process
  20. var ELogWinInit = ""; // save for ElogWin init HTML
  21. var AgentWinInit = "";
  22. var ELBgFlg = 0; // Alert Event Log Backgrounf color toggle
  23. var ELIdx = 0; // Discovery Log Index
  24. var ELChkBoxCount = 0; // Discovery Log check box 
  25. var PuPW = "400px", PuPWu=400, PuPH = "280px", PuPHu=270, PuPCH = "235px";
  26. var AddServicesArr = new Array();
  27. var AddServicesArrIdx = 0;
  28. var AddServicesFlag = 0; //1=Add with Edit first; 2=Add without Edit
  29. var tpingchk=false ,tpingto="5",tpingret="";
  30. var thttpchk=false,thttpport="",thttpto="5",thttplookfor="",thttponpage="";
  31. var tftpchk=false,tftpport="",tftpto="5";
  32. var ttelchk=false, ttelport="", ttelto="5";
  33. var tsmtpchk=false,tsmtpport="",tsmtpto="5";
  34. var tpopchk=false,tpopport="",tpopto="5";
  35. var tdnschk=false,tdnsport="",tdnsto="5",tdnsret="",tdnsname="";
  36. var tuserchk=false,tuserport="",tuserto="5",tuserret="",tuserrqst="",tuserresp="",tuserpart="";
  37. var tsqlchk=false,tsqlto="",tsqlparms=",sa,,";
  38. var toraclechk=false,toracleto="",toracleparms=",sa,,";
  39. var tsnmpchk=false,tsnmpto="5",tsnmpret="",tsnmpparms="public,public,1";
  40. var thttpsec=tftpsec=tpopsec=tsmtpsec=ttelsec="";
  41. var tlnoteschk=false,tlnotesport="",tlnotesto="5",tlnotesret="",tlnotesrqst="",tlnotesresp="",tlnotespart="";
  42.  
  43. var DefaultServiceTimeOut = "5"; // seconds
  44. var DefaultPingTimeOut = "2"; // seconds
  45. var ServiceTypeCount=11; // count of services monitored
  46.  
  47. var FStorIdx = null; // Index to Found Service in Store
  48. var ServEditCID = null; // Edited Computer ID
  49. var ServStorIdx = null; // Index to Start of Services in Store for Computer ID
  50. var ServEditMode = null; // Database Operation Required for Edit Update
  51. var ServEditCount = 0; // Count of Services Updated
  52. var ServiceCompID = null; // Computer ID for current Service Records Received
  53. var ServAddStrg = null; // Service Record Store string
  54. var TotalComputersAdded = 0; // count of computers added from Discovery
  55. var ignoreDBChangeEvent = 0;
  56. var LicenseMax = 10; // maximum licenses available
  57. var LicenseCur = 0; // current license used
  58. var ServiceThreadToggleRequired = false;
  59.  
  60. var AC_StoreArr = new Array();
  61. var ComputerRecLength = 12; // Computer Lookup record length
  62. var LupRecCount = 0; // Count of records returned from Computer Lookup operation
  63.  
  64. var AC_ServicesStoreArr = new Array();
  65. var ServicesRecCount = 0; // Count of records returned from Services Lookup operation
  66. var ServicesRecLength = 2; // Services Lookup record length
  67.  
  68. var EnumeratedServersArr = new Array();
  69. var EnumeratedServersRecLength = 7;
  70.  
  71. var CurrentLocalDomain = "";
  72.  
  73. var ReconnectEvent = false;
  74. var Hp = 82;
  75. var LastNew = "";
  76.  
  77. var DtypTxt = new Array("",""," -workgroup"," -standalone");
  78.  
  79. // Server type flags
  80. var SV_TYPE_WORKSTATION =        0x00000001
  81. var SV_TYPE_SERVER =             0x00000002
  82. var SV_TYPE_SQLSERVER =          0x00000004
  83. var SV_TYPE_DOMAIN_CTRL =        0x00000008
  84. var SV_TYPE_DOMAIN_BAKCTRL =     0x00000010
  85. var SV_TYPE_TIME_SOURCE  =       0x00000020
  86. var SV_TYPE_AFP  =               0x00000040
  87. var SV_TYPE_NOVELL  =            0x00000080
  88. var SV_TYPE_DOMAIN_MEMBER =      0x00000100
  89. var SV_TYPE_PRINTQ_SERVER =      0x00000200
  90. var SV_TYPE_DIALIN_SERVER =      0x00000400
  91. var SV_TYPE_XENIX_SERVER  =      0x00000800
  92. var SV_TYPE_SERVER_UNIX =        SV_TYPE_XENIX_SERVER
  93. var SV_TYPE_NT  =                0x00001000
  94. var SV_TYPE_WFW  =               0x00002000
  95. var SV_TYPE_SERVER_MFPN  =       0x00004000
  96. var SV_TYPE_SERVER_NT  =         0x00008000
  97. var SV_TYPE_POTENTIAL_BROWSER =  0x00010000
  98. var SV_TYPE_BACKUP_BROWSER =     0x00020000
  99. var SV_TYPE_MASTER_BROWSER =     0x00040000
  100. var SV_TYPE_DOMAIN_MASTER =      0x00080000
  101. var SV_TYPE_SERVER_OSF  =        0x00100000
  102. var SV_TYPE_SERVER_VMS =         0x00200000
  103. var SV_TYPE_WINDOWS  =           0x00400000  // Windows95 and above 
  104. var SV_TYPE_DFS =                0x00800000  // Root of a DFS tree 
  105. var SV_TYPE_CLUSTER_NT  =        0x01000000  // NT Cluster 
  106. var SV_TYPE_DCE =                0x10000000  // IBM DSS (Directory and Security Services) or equivalent 
  107. var SV_TYPE_ALTERNATE_XPORT =    0x20000000  // return list for alternate transport 
  108. var SV_TYPE_LOCAL_LIST_ONLY =    0x40000000  // Return local list only 
  109. var SV_TYPE_DOMAIN_ENUM =        0x80000000
  110. var SV_TYPE_ALL  =               0xFFFFFFFF  // handy for NetServerEnum2 
  111.  
  112. /* On Load tell the Comm control to Connect to the Server */
  113. function InitRpmCC_AC() {
  114.     top.MainLoaded = true; // Flag that Main is now loaded
  115.     initButtonState(); // set initial button state for all buttons
  116.     ELogWinInit = ELogWin.innerHTML; // save init state
  117.     AgentWinInit = AgentWin.innerHTML; // save init state
  118.     byM = 2*parseFloat(document.body.style.margin);
  119.     processSizeChange();
  120.     
  121.     // Initialize Port Base field
  122.     var IPArr = document.body.RPMHostIP.split(".");
  123.  
  124.     if ( IPArr[0] == "127" && IPArr[1] == "0" ) {
  125.        IPArr = origRPMHostIP.split(".");
  126.         if ( IPArr.length < 4 ) {
  127.             IPArr = RpmMIL.ResolveNameToIPAddr(origRPMHostIP).split(".");
  128.         }
  129.    }
  130.    else if ( IPArr.length < 4 ) {
  131.         IPArr = RpmMIL.ResolveNameToIPAddr(origRPMHostIP).split(".");
  132.     }
  133.  
  134.     quad1.value = IPArr[0];
  135.     quad2.value = IPArr[1];
  136.     quad3.value = IPArr[2];
  137.  
  138.     /* Get Discovery Show All & Get Domain checkbox state */
  139.     cc = top.banner.RpmCC_Ban.RegGetKey(top.banner.ServerID+"DiscoveryShowAllState"); // get state
  140.     if ( cc == "unchecked" ) { // If not checked 
  141.         ShowAllEnabled.checked = "";
  142.     }
  143.     else { 
  144.         ShowAllEnabled.checked = "CHECKED";
  145.     }
  146.     cc = top.banner.RpmCC_Ban.RegGetKey(top.banner.ServerID+"DiscoveryGetDomainState"); // get state
  147.     if ( cc == "unchecked" ) { // If not checked 
  148.         DomainLUP.checked = "";
  149.     }
  150.     else { 
  151.         DomainLUP.checked = "CHECKED";
  152.     }
  153.     cc = top.banner.RpmCC_Ban.RegGetKey(top.banner.ServerID+"ShowAllDomain"); // get state
  154.     if ( cc == "unchecked" ) { // If not checked 
  155.         ShowAllDomain.checked = "";
  156.     }
  157.     else { 
  158.         ShowAllDomain.checked = "CHECKED";
  159.     }
  160.     cc = top.banner.RpmCC_Ban.RegGetKey(top.banner.ServerID+"DomainFilter"); // get state    
  161.     if ( cc != "" ) {
  162.         var warr = new Array();
  163.         warr = cc.split("~");
  164.         filter_servers.checked = warr[0]; 
  165.         filter_ws.checked = warr[1]; 
  166.         filter_pdc.checked = warr[2]; 
  167.         filter_bdc.checked = warr[3]; 
  168.         filter_sql.checked = warr[4]; 
  169.         filter_notdc.checked = warr[5]; 
  170.         filter_cluster.checked = warr[6]; 
  171.         filter_pq.checked = warr[7]; 
  172.     }
  173.     Hp = parseInt(document.body.RPMHostPort,10);
  174.     RpmCC_AC.Connect(document.body.RPMHostIP, Hp, "");
  175. }
  176. function processConnectConfirmed() {
  177.     processResetDone();
  178.     SetButtonState(CResetButton,"1");
  179.     SetButtonState(CUpdateButton,"1");
  180.     SetButtonState(CEditButton,"1");
  181.     SetButtonState(CDupButton,"1");
  182.     SetButtonState(CDeleteButton,"1");
  183.     SetButtonState(CNewButton,"1");
  184.  
  185.     SetButtonState(DiscoveryButton,"1");
  186.     SetButtonState(InstallAgentButton,"1");
  187.     SetButtonState(ManageAgentsButton,"1");
  188.     SetButtonState(WMButton,"1");
  189.     
  190.     if ( ReconnectEvent == false ) {
  191.         RpmCC_AC.GetLicenseCount(); // get Server license count
  192.         IMode = "Lookup";
  193.         UserLupRecCount = 0; // clear Lookup record counter
  194.         AC_DomainArr.length = 0;
  195.         if ( RpmCC_AC.UserLookup("DOMAINNAME:","") ) {
  196.             top.Rstatus.Pstat("Unable to start the SERVER LOOKUP request",true);
  197.             IMode = ""; // reset
  198.         }
  199.         ReconnectEvent = true;
  200.     }
  201.     top.Rstatus.Pstat("Connected");
  202.     if ( Tid != null ) {
  203.         clearTimeout(Tid); // stop timeout routine
  204.     }
  205.     Tid = setTimeout("processConnectionCheck()",30000); // Delay 30 secs then check connection
  206. }
  207. function processReconnect() {
  208.     Tid = null;
  209.     if ( RpmCC_AC.IsConnected() ) {
  210.         Tid = setTimeout("processConnectionCheck()",30000); // Delay 30 secs then check connection
  211.         return;
  212.     }
  213.     RpmCC_AC.Connect(document.body.RPMHostIP,Hp, ""); 
  214. }
  215. function processConnectionCheck() {
  216.     Tid = null;
  217.     RpmCC_AC.SendKeepAlive("Check");
  218.     Tid = setTimeout("processConnectionCheck()",30000); // Delay 30 secs then check connection
  219. }
  220.  
  221. /* On Unload tell the Comm control to Disconnect from the Server */
  222. function DiscoRpmCC_AC() {
  223.     top.QuickStartProcessing = false;
  224.     RpmCC_AC.Disconnect();
  225.     top.banner.processStopCommX();
  226.     if ( Tid != null ) {
  227.         clearTimeout(Tid); // stop timeout routine
  228.     }
  229.     if ( CTid != null ) {
  230.         clearTimeout(CTid); // stop timeout routine
  231.     }
  232.     // Save Discovery Show All & Get Domain checkbox state
  233.     cc = ( ShowAllEnabled.checked == false ) ? "unchecked" : "checked";
  234.     top.banner.RpmCC_Ban.RegSetKey(top.banner.ServerID+"DiscoveryShowAllState",cc); // set state
  235.     cc = ( DomainLUP.checked == false ) ? "unchecked" : "checked";
  236.     top.banner.RpmCC_Ban.RegSetKey(top.banner.ServerID+"DiscoveryGetDomainState",cc); // set state
  237.     cc = ( ShowAllDomain.checked == false ) ? "unchecked" : "checked";
  238.     top.banner.RpmCC_Ban.RegSetKey(top.banner.ServerID+"ShowAllDomain",cc); // set state
  239.     
  240.     var warr = new Array();
  241.     warr[0] = ( filter_servers.checked ) ? "checked" : "";
  242.     warr[1] = ( filter_ws.checked ) ? "checked" : "";
  243.     warr[2] = ( filter_pdc.checked ) ? "checked" : "";
  244.     warr[3] = ( filter_bdc.checked ) ? "checked" : "";
  245.     warr[4] = ( filter_sql.checked ) ? "checked" : "";
  246.     warr[5] = ( filter_notdc.checked ) ? "checked" : "";
  247.     warr[6] = ( filter_cluster.checked ) ? "checked" : "";
  248.     warr[7] = ( filter_pq.checked ) ? "checked" : "";
  249.     cc = warr.join("~");
  250.     top.banner.RpmCC_Ban.RegSetKey(top.banner.ServerID+"DomainFilter",cc); // set state    
  251. }
  252.  
  253. /* Process Domain LOOKUP RECORD Event */
  254. var AC_DomainArr = new Array();
  255. var UserRecLength = 6;
  256. var UserLupRecCount = 0;
  257. function processUserLookupRecord(Did,DName,DDesc,UPswd,UName,UItype) {
  258.     var i = UserRecLength * UserLupRecCount;
  259.     if ( i == 0 ) { // if first one    
  260.         AC_DomainArr[i+0] = "(ALL)";
  261.          AC_DomainArr[i+1] = "0";
  262.         AC_DomainArr[i+2] = "All Domains Listed";
  263.         AC_DomainArr[i+3] = "";
  264.         AC_DomainArr[i+4] = "";
  265.         AC_DomainArr[i+5] = "0";
  266.         ++UserLupRecCount; // bump record received counter
  267.        i = UserRecLength * UserLupRecCount;       
  268.     }
  269.     AC_DomainArr[i+0] = DName;
  270.     AC_DomainArr[i+1] = Did;
  271.     AC_DomainArr[i+2] = DDesc;
  272.     AC_DomainArr[i+3] = UPswd;
  273.     AC_DomainArr[i+4] = UName;
  274.     AC_DomainArr[i+5] = UItype;
  275.     ++UserLupRecCount; // bump record received counter
  276. }
  277. /* Process DB Error in User Lookup Operation */
  278. function processUserOpError() {
  279.     top.Rstatus.Pstat("An error occurred during Domain LOOKUP operation",true);
  280. }
  281. function processUserOpComplete() {
  282. // Look up MonitorIT Servers
  283.     if ( RpmCC_AC.AdminServersLookup("*") ) {
  284.         top.Rstatus.Pstat("Unable to start the SERVER LOOKUP request",true);
  285.         IMode = ""; // reset
  286.     }
  287. }
  288.  
  289. // Process Display View Size Change
  290. var SCbsy = false;
  291. var MomPuPW = "330px", MomPuPWu=330;
  292. var PuPOIDW = "500px", PuPOIDWu=500, PuPOIDCH = "326px";
  293. function processSizeChange() {
  294.     if ( SCbsy ) 
  295.         return;
  296.     SCbsy = true;
  297.     // Display Height and Width
  298.     bCh = document.body.clientHeight;
  299.     bCw = document.body.clientWidth;
  300.     
  301.    // PopUp 
  302.    PuPLeft = (bCw-PuPWu)/2;
  303.    PuPTop = (bCh-PuPHu)/2;
  304.    PopUpDiv.style.left = PuPLeft+"px"; 
  305.    PopUpDiv.style.top = "1px"; //PuPTop+"px"; 
  306.    PopUpDiv.style.height = PuPH;
  307.    PopUpDiv.style.width = PuPW;
  308.   
  309.    PopUpConfirm.style.left = PuPLeft+"px"; 
  310.    PopUpConfirm.style.top = "150px"; //PuPTop+"px"; 
  311.    PopUpConfirm.style.height = PuPCH;
  312.    PopUpConfirm.style.width = PuPW;
  313.  
  314.    PopUpDomain.style.left = ((bCw-300)/2)+"px"; 
  315.    PopUpDomain.style.top = "180px"; 
  316.    PopUpDomain.style.height = "100px";
  317.    PopUpDomain.style.width = "300px";
  318.  
  319.    PopUpAI.style.left = ((bCw-400)/2)+"px"; 
  320.    PopUpAI.style.top = "180px"; 
  321.    PopUpAI.style.height = "130px";
  322.    PopUpAI.style.width = "400px";
  323.  
  324.    LogonInfo.style.left = ((bCw-400)/2)+"px"; 
  325.    LogonInfo.style.top = "135px"; 
  326.    LogonInfo.style.height = "100px";
  327.    LogonInfo.style.width = "400px";
  328.   
  329.      //PopUpContext Menu
  330.    PopUpContextSize(bCw);
  331.  
  332.    // Set Height/Widths for Log areas
  333.     ELogWinMain.style.left = (byM+3)+"px";
  334.     ELogWinMain.style.top = "45px"; //"180px";
  335.     ELogWinMain.style.height = bCh-(bdH+byM-borderSz)-65; // "340px"
  336.     ELogWinMain.style.width = bCw-byM-byM-6;
  337.     ELogWin.style.height = bCh-(bdH+byM-borderSz)-65-55;
  338.  
  339.     AgentWinMain.style.left = (byM+3)+"px";
  340.     AgentWinMain.style.top = "45px"; //"180px";
  341.     AgentWinMain.style.height = bCh-(bdH+byM-borderSz)-65; // "340px"
  342.     AgentWinMain.style.width = bCw-byM-byM-6;
  343.     AgentWin.style.height = bCh-(bdH+byM-borderSz)-65-75;    
  344.  
  345.    DomainFilter.style.left = ((bCw-360)/2)+"px"; 
  346.    DomainFilter.style.top = "65px"; 
  347.    DomainFilter.style.height = "130px";
  348.    DomainFilter.style.width = "360px";
  349.  
  350.    PuPWMLeft = (bCw-620)/2;
  351.     PopUpWatchMember.style.left = PuPWMLeft+"px"; 
  352.    PopUpWatchMember.style.top = "100px"; //PuPTop+"px"; 
  353.    PopUpWatchMember.style.height = (bCh-130)+"px"; //"426px";
  354.    PopUpWatchMember.style.width = "620px";
  355.    WM_Data.style.height = PopUpWatchMember.style.posHeight-50;//"325px";
  356.  
  357.    PuPWMIRLeft = (bCw-620)/2;
  358.     PopUpWMIReport.style.left = PuPWMIRLeft+"px"; 
  359.    PopUpWMIReport.style.top = "100px"; //PuPTop+"px"; 
  360.    PopUpWMIReport.style.height = (bCh-130)+"px"; //"426px";
  361.    PopUpWMIReport.style.width = "620px";
  362.    WMIR_Data.style.height = PopUpWMIReport.style.posHeight-50;//"325px";
  363.  
  364.    PuPOIDLeft = (bCw-PuPOIDWu)/2;
  365.    PopUpOID.style.left = PuPOIDLeft+"px"; 
  366.    PopUpOID.style.top = "200px"; //PuPTop+"px"; 
  367.    PopUpOID.style.height = PuPOIDCH;
  368.    PopUpOID.style.width = PuPOIDW;
  369.  
  370.       // PopUp 
  371.    MomPuPLeft = (bCw-MomPuPWu)/2;
  372.    PopUpMoment.style.left = MomPuPLeft+"px"; 
  373.    PopUpMoment.style.top = "125px"; 
  374.    PopUpMoment.style.height = "135px";
  375.    PopUpMoment.style.width = MomPuPW;
  376.     
  377.     SCbsy = false;
  378. }
  379.  
  380.  
  381. /* Process Click on selected Tab */
  382. var CurSelTab = null; // current selected tab
  383. function processGeneralClick(th) {
  384.     CounterUI.style.display="none";
  385.     ServicesUI.style.display="none";
  386.     SNMPUI.style.display="none";
  387.     CounterTab.className="TabUnsel";
  388.     ServicesTab.className="TabUnsel";
  389.     SNMPTab.className="TabUnsel";
  390.     th.className="TabSel";
  391.  
  392.     CurSelTab = th.id;
  393.     switch ( th.id ) {
  394.    case "CounterTab" : 
  395.       CounterUI.style.display=""; // Enable this Tab's view
  396.       break;
  397.    case "ServicesTab" : 
  398.        ServicesUI.style.display=""; // Enable this Tab's view
  399.       break;
  400.    case "SNMPTab" : 
  401.         if ( GotMIBData ) {
  402.             displayMIBObjectChoices();
  403.         }
  404.         else {
  405.               processGetMIBList(0); // get the MIB Object List
  406.         }   
  407.        SNMPUI.style.display=""; // Enable this Tab's view
  408.         AC_MIBSel.style.visibility="visible";
  409.       break;
  410.     }
  411.     /* Select current Computer Name and give it focus */
  412.     if ( AC_NameSel.length > 0 ) {
  413.         AC_NameSel.options[CurSelectIdx].selected = "selected";
  414.         if ( AC_NameSel.style.visibility != "hidden" && AC_NameSel.style.display == "") {
  415.             AC_NameSel.focus();
  416.         }
  417.     }
  418. }
  419.  
  420. // Process the New Button Press
  421. function processNewButton() {
  422.     CMode = "New"; // Set Mode of operation
  423.     tpingchk = "checked"; // default to PING service enabled
  424.     thttpport = "80"; thttplookfor = ""; thttponpage = "";
  425.     tftpport = "21"; 
  426.     tsmtpport = "25"; 
  427.     tpopport = "110"; 
  428.     tdnsport = "53"; 
  429.     tuserport = "100";
  430.     ttelport = "23";
  431.     tlnotesport = "1352";
  432.     tdnsret = tpingret = tuserret = tsnmpret = "2";
  433.     thttpto = tftpto = tsmtpto = tpopto = tdnsto = ttelto = tuserto = tsqlto = tsnmpto = DefaultServiceTimeOut;
  434.     tlnotesto = toracleto = DefaultServiceTimeOut;
  435.     thttpsec=tftpsec=tpopsec=tsmtpsec=ttelsec="";
  436.     tpingto = DefaultPingTimeOut;  
  437.     processServiceSelectPut(); // set up display
  438.     TotalComputersAdded = 0; // initialize
  439.     
  440.     AC_SNMPEnabled.checked = "";
  441.  
  442.     AC_Name.value = "";
  443.     AC_Group.value = "";
  444.     AC_Pswd.value = "";
  445.     AC_VPswd.value = "";
  446.     AC_Desc.value = "";    
  447.     AC_IPAddr.value = "";
  448.     AC_Server.value = "";
  449.     AC_DomainN.value = "";    
  450.     AC_OSver.value = "";    
  451.     AC_AgentVer.value = "";
  452.  
  453.     commonNew_Edit(); // Do common processing
  454.     
  455.     for ( var i=0; i<MIBObjectArr.length; i++ ) {
  456.         MIBObjectCheckArr[i] = "0";   
  457.     }    
  458.     AC_MIBSel.length = 0;
  459.     AC_SNMPPort.value = "161";
  460.     AC_ReadComm.value = "public";
  461.  
  462.     AC_GroupSel.options[0].selected = "selected";     // Select first Group
  463.     AC_Group.value = AC_GroupSel.options[0].text; // Sync the field
  464.     AC_ServerSel.options[0].selected = "selected"; // Prime Port field
  465.     AC_Server.value = AC_ServerSel.options[0].text; // Sync the field
  466.     AC_DomainNSel.options[0].selected = "selected"; // Prime Port field
  467.     AC_DomainN.value = AC_DomainNSel.options[0].value; // Sync the field
  468.     AC_Port.value = ""+document.body.RPMAgentPort; // Prime Agent Port field
  469.     SetButtonState(DiscoveryButton,"0");
  470.     SetButtonState(VerifyButton,"0");
  471.     top.Rstatus.Pstat("Ready");
  472. }            
  473.  
  474. function processDuplicateButton() {
  475.     CMode = "New"; // Set Mode of operation
  476.     AC_Name.value = "";
  477.     TotalComputersAdded = 0; // initialize
  478.     commonNew_Edit(); // Do common processing
  479.     SetButtonState(VerifyButton,"0");
  480.     getGroupID(AC_Group.value,AC_GrpStore); // Set GrpSelectIdx
  481.     AC_GroupSel.options[GrpSelectIdx].selected = "selected";    
  482.     getServerID(AC_Server.value);
  483.     AC_ServerSel.options[SrvSelectIdx].selected = "selected";
  484.     top.Rstatus.Pstat("Done"); 
  485.     processGetMIBList(0); // get the MIB Object List
  486. }    
  487.  
  488. function processEditButton() {
  489.     CMode = "Edit"; // Set Mode of operation
  490.     AC_Name.value = AC_NameSel.options[CurSelectIdx].text; // Selected Computer Name
  491.     commonNew_Edit(); // Do common processing
  492.     SetButtonState(VerifyButton,"0");
  493.     getGroupID(AC_Group.value,AC_GrpStore); // Set GrpSelectIdx
  494.     AC_GroupSel.options[GrpSelectIdx].selected = "selected";    
  495.     getServerID(AC_Server.value);
  496.     AC_ServerSel.options[SrvSelectIdx].selected = "selected";
  497.     top.Rstatus.Pstat("Done"); 
  498.     processGetMIBList(0); // get the MIB Object List
  499. }    
  500.  
  501. function processLookupButton() {
  502.     CMode = "Lookup"; // set mode of operation
  503.     AC_NameSel.className = "idis";
  504.     AC_Group.className = "idis";
  505.     AC_MIBSel.className = "idis";
  506.  
  507.     /* inhibit combo Group Name; enable one-line input Group Name */
  508.     AC_GroupSel.style.display = "none";
  509.     AC_Group.style.display = "";
  510.  
  511.     /* Initiate DataBase Computer Lookup Operation */
  512.     LupRecCount = 0; // initialize record counter
  513.     ServiceCompID = null; // init the Service Record Computer ID
  514.     CurSelectIdx = 0; // reset current select index
  515.     allGrpSelected = true; 
  516.     AC_StoreArr.length = 0;
  517.     
  518.     for ( var i=AC_NameSel.length; i>0; i-- ) {
  519.        AC_NameSel.remove(0);
  520.     }
  521.     if ( RpmCC_AC.ComputerLookup("*","*") ) {
  522.         top.Rstatus.Pstat("Unable to start the LOOKUP request",true);
  523.         processResetButton();
  524.     }
  525.     else { // waiting for OperationCompleteEvent
  526.           SetCursor("wait");
  527.           top.banner.processStartComm();
  528.         top.Rstatus.Pstat("One moment while LOOKUP request completes");
  529.     }
  530. }    
  531.  
  532. // Manage All Agents
  533. var acds = acns = acgs = acms = "";
  534. var CurrentAgentVersion = "";
  535. var saveCMode = "", saveNameSelClass="", saveNameSelDisplay="";
  536.  
  537. function processManageAgentButton() {
  538.     ServiceSelect.style.display="none";
  539.     acns = AC_NameSel.style.display;
  540.     AC_NameSel.style.display = "none";
  541.     acgs = AC_GroupSel.style.display;
  542.     AC_GroupSel.style.display = "none";
  543.     acds = AC_DomainNSel.style.display;
  544.     AC_DomainNSel.style.display = "none";
  545.     acms = AC_MIBSel.style.display;
  546.     AC_MIBSel.style.display = "none";
  547.     AgentWinMain.style.display = "";
  548.     if (filter_domainnameSel.selectedIndex < 0)
  549.          filter_domainnameSel.selectedIndex = 0; // default to Filter All
  550.     processRefreshButton();
  551. }    
  552. function processShowAllFilter() {
  553.     // Populate Domain Names if any
  554.     if ( AC_DomainArr.length == 0 ) {
  555.         filter_domainnameSel.style.display = "none";
  556.         filter_domainname.style.display = "";   
  557.     }
  558.     else {
  559.         filter_domainnameSel.style.display = "";
  560.         filter_domainname.style.display = "none";
  561.         lth = filter_domainnameSel.length;
  562.         for (i=0; i < lth; ++i)
  563.             filter_domainnameSel.remove(0);
  564.         for ( var i=0; i<AC_DomainArr.length; i+=UserRecLength ) {
  565.             if ( AC_DomainArr[i+5] != "3" ) {
  566.                 addElementToSelect( filter_domainnameSel, AC_DomainArr[i]+DtypTxt[parseInt(AC_DomainArr[i+5],10)] );
  567.             }
  568.         }        
  569.         if ( CurrentFilterSelectedIndex < filter_domainnameSel.length )
  570.             filter_domainnameSel.selectedIndex = CurrentFilterSelectedIndex;
  571.     }
  572.     DomainFilter.style.display="";
  573. }
  574. var CurrentFilterSelectedIndex = 0;
  575. function processDomainFilterOKButton() {
  576.     DomainFilter.style.display="none";
  577.     CurrentFilterSelectedIndex = filter_domainnameSel.selectedIndex;
  578. }
  579.  
  580. var CurrentDomainIndex = 0;
  581. var CurrentDomainEnumerated = "";
  582. function processGetDomainAndFilterSpec() {
  583.     var filter = 0x0;
  584.     if ( filter_servers.checked ) filter |= SV_TYPE_DOMAIN_CTRL | SV_TYPE_DOMAIN_BAKCTRL | SV_TYPE_SERVER_NT | SV_TYPE_CLUSTER_NT;
  585.     if ( filter_ws.checked ) filter |= SV_TYPE_WORKSTATION;
  586.     if ( filter_pdc.checked ) filter |= SV_TYPE_DOMAIN_CTRL;
  587.     if ( filter_bdc.checked ) filter |= SV_TYPE_DOMAIN_BAKCTRL;
  588.     if ( filter_sql.checked ) filter |= SV_TYPE_SQLSERVER;
  589.     if ( filter_notdc.checked ) filter |= SV_TYPE_SERVER_NT;
  590.     if ( filter_cluster.checked ) filter |= SV_TYPE_CLUSTER_NT;
  591.     if ( filter_pq.checked ) filter |= SV_TYPE_PRINTQ_SERVER;
  592.     var dfspec = ""+filter+"~"+filter_domainname.value;
  593.     CurrentDomainEnumerated = ( filter_domainname.value == "" ) ? CurrentLocalDomain : filter_domainname.value;
  594.     if ( CurrentDomainIndex > 0 ) {     
  595.         while ( CurrentDomainIndex < AC_DomainArr.length/UserRecLength ) {
  596.             if ( AC_DomainArr[(CurrentDomainIndex * UserRecLength)+5] == "3" ) {
  597.                 ++CurrentDomainIndex;
  598.                 continue;
  599.             }
  600.             else {
  601.                 break;
  602.             }   
  603.         }
  604.         if ( CurrentDomainIndex < AC_DomainArr.length/UserRecLength ) {
  605.            dfspec = ""+filter+"~"+AC_DomainArr[(CurrentDomainIndex * UserRecLength)];
  606.            CurrentDomainEnumerated = AC_DomainArr[(CurrentDomainIndex * UserRecLength)];
  607.            return dfspec;
  608.        }
  609.        else {
  610.            return "";
  611.        }
  612.      }
  613.      return dfspec;
  614. }
  615. function processRefreshButton() {
  616.     saveCMode = CMode;
  617.     CMode = "Lookup_ManageAgent"; // set mode of operation
  618.     processAgentWindow(); // init the display
  619.     SetButtonState(GlobalInstallAgentButton,"1"); // disable
  620.     SetButtonState(RefreshButton,"1"); // disable
  621.     allGrpSelected = true; 
  622.     LupRecCount = 0; // initialize record counter
  623.     ServiceCompID = null; // init the Service Record Computer ID
  624.     CurSelectIdx = 0; // reset current select index
  625.     AC_StoreArr.length = 0;
  626.     MomText.innerHTML = "";
  627.     PopUpMoment.style.display = "";
  628.     SetCursor("wait");
  629.     top.banner.processStartComm();
  630.  
  631.       CurrentDomainIndex = 0;
  632.     EnumeratedServersArr.length = 0; // reset array
  633.     if ( AC_DomainArr.length > 0 ) {
  634.         // if nothing selected, default to all
  635.         if ( filter_domainnameSel.selectedIndex < 0 ) {
  636.             filter_domainnameSel.selectedIndex = 0;
  637.             CurrentDomainIndex = 1; // start with First
  638.         } 
  639.         // If All
  640.         else if ( filter_domainnameSel.selectedIndex == 0 ) {
  641.             CurrentDomainIndex = 1; // start with first
  642.         }
  643.         // Specific Domain
  644.         else {
  645.             filter_domainname.value = AC_DomainArr[(filter_domainnameSel.selectedIndex * UserRecLength)];
  646.         }            
  647.     }
  648.     for ( var i=AC_NameSel.length; i > 0; i-- ) {
  649.        AC_NameSel.remove(0);
  650.     }
  651.     if ( RpmCC_AC.ComputerLookup("*","*") ) {
  652.         processManageAgentContinue();
  653.     }
  654. }
  655.  
  656. function processManageAgentContinue() {
  657.     if (     AgentWinMain.style.display != "" ) 
  658.         return;
  659.         
  660.     if ( CurrentDomainIndex > 0 && ShowAllDomain.checked ) {
  661.         if ( ++CurrentDomainIndex < AC_DomainArr.length/UserRecLength ) {
  662.             var filter = processGetDomainAndFilterSpec();
  663.             if ( filter != "" ) {
  664.                 top.Rstatus.Pstat("Searching Windows Domain/Workgroup-"+CurrentDomainEnumerated);
  665.                 MomText.innerHTML = "Searching Windows Domain/Workgroup-<br><b>'"+CurrentDomainEnumerated+"'</b><br>Total Found - <b>"+(EnumeratedServersArr.length/EnumeratedServersRecLength)+"</b>";
  666.                 RpmCC_AC.GetEnumeratedServers(filter); // go enumerate servers/workstations
  667.                 return; 
  668.             }
  669.         }
  670.     }
  671.     SetCursor("auto");
  672.       top.banner.processStopCommX();
  673.     PopUpMoment.style.display = "none";
  674.     CMode = saveCMode;
  675.     ELBgFlg = 0; // flag for alternating background color
  676.     ELIdx = 0; // output log index
  677.     var lce = "";
  678.     var AgentLCArr = new Array();    
  679.     var AgentSortArr = new Array();
  680.     var warr = new Array();
  681.     var aarr = new Array();
  682.  
  683.     for (var i=0, j=0; i < AC_StoreArr.length; i+=ComputerRecLength, ++j) {
  684.         lce = AC_StoreArr[i].toLowerCase();
  685.         AgentLCArr[j] = lce;
  686.         AgentSortArr[j] = lce+"[]"+i+"[]"+"0"+"[]";
  687.     }
  688.     if ( ShowAllDomain.checked ) {
  689.         var asamax = j;
  690.         var stype = 0;
  691.         for ( i=0; i<EnumeratedServersArr.length-1; i+= EnumeratedServersRecLength ) {
  692.             // Filter out any there are not NT/2000/XP
  693.             stype = parseInt( EnumeratedServersArr[i+5],16 );
  694.             if ( !(stype & SV_TYPE_NT) ) 
  695.                 continue;
  696.  
  697.             // Filter out entries already in the Computer table
  698.             lce = EnumeratedServersArr[i+1].toLowerCase();
  699.             for ( var k=0; k<asamax; k++ ) {
  700.                 if ( lce == AgentLCArr[k] ) 
  701.                     break;
  702.             }
  703.             EnumeratedServersArr[i] = (EnumeratedServersArr[i] == "") ? CurrentLocalDomain : EnumeratedServersArr[i];
  704.             if ( k < asamax ) {
  705.                 aarr = AgentSortArr[k].split("[]");
  706.                 aarr[3] = EnumeratedServersArr[i]; // Domain Name
  707.                 AgentSortArr[k] = aarr.join("[]");
  708.                 continue;        
  709.             }
  710.             AgentSortArr[j++] = lce+"[]"+i+"[]"+"1"+"[]"+EnumeratedServersArr[i];
  711.         }
  712.     }
  713.     AgentSortArr.sort();
  714.     AgentObjectArray.length = 0; // reset
  715.     AgentCheckBoxObjectArray.length = 0;
  716.     
  717.     for (var i=0; i < AgentSortArr.length; ++i) {
  718.         warr = AgentSortArr[i].split("[]");    
  719.         processAgentWindowEntry(parseInt(warr[1],10),warr[2],warr[3]);
  720.     }
  721.     SetButtonState(RefreshButton,"0"); // enable
  722.     AgentCheckedCount = 0;
  723.     top.Rstatus.Pstat("Current Agent Version is: "+CurrentAgentVersion,true);
  724. }
  725. function processManageAgentResetButton() {
  726.     top.Rstatus.Pstat("");
  727.     AgentWinMain.style.display="none";
  728.     DomainFilter.style.display="none";
  729.     LogonInfo.style.display = "none";
  730.     AC_GroupSel.style.display=acgs;
  731.     AC_DomainNSel.style.display=acds;
  732.     AC_NameSel.style.display=acns;
  733.     AC_MIBSel.style.display=acms;
  734.     allDeselectGroup(AC_GroupSel); // deselect all in Group
  735.     ServiceSelect.style.display="";
  736.     PopUpMoment.style.display = "none";
  737.     SetCursor("auto");
  738.       top.banner.processStopCommX();
  739. }
  740.  
  741. function processSort(scode) {
  742.     var warr = new Array();
  743.     var SortArr = new Array;
  744.     var sparm = "";
  745.     ELBgFlg = 0; // flag for alternating background color
  746.     ELIdx = 0; // output log index
  747.     
  748.     for (var i=0; i < AgentObjectArray.length; ++i) {
  749.         if ( scode == 0 ) { sparm = AgentObjectArray[i].aver; }
  750.         else if ( scode == 2 ) { 
  751.             sparm = (AgentObjectArray[i].tflag == "0") ? AC_StoreArr[parseInt(AgentObjectArray[i].cidx,10)+5].toLowerCase() :
  752.                             EnumeratedServersArr[parseInt(AgentObjectArray[i].cidx,10)+2].toLowerCase();
  753.         }
  754.         else if ( scode == 3 ) { 
  755.             sparm = AgentObjectArray[i].ddom.toLowerCase() + ( (AgentObjectArray[i].tflag == "0") ? 
  756.                          AC_StoreArr[parseInt(AgentObjectArray[i].cidx,10)].toLowerCase() : 
  757.                          EnumeratedServersArr[parseInt(AgentObjectArray[i].cidx,10)+1].toLowerCase() );
  758.         }
  759.         else { sparm = (AgentObjectArray[i].tflag == "0") ? AC_StoreArr[parseInt(AgentObjectArray[i].cidx,10)].toLowerCase() :
  760.                         EnumeratedServersArr[parseInt(AgentObjectArray[i].cidx,10)+1].toLowerCase();
  761.         }
  762.         SortArr[i] = sparm+"???"+AgentObjectArray[i].cidx+"???"+AgentObjectArray[i].tflag+"???"+AgentObjectArray[i].pdom;
  763.     }
  764.     SortArr.sort();
  765.     AgentText.innerHTML = "";
  766.     AgentObjectArray.length = 0; // reset
  767.     AgentCheckBoxObjectArray.length = 0;
  768.     for (var i=0; i < SortArr.length; ++i) {
  769.         warr = SortArr[i].split("???");    
  770.         processAgentWindowEntry(parseInt(warr[1],10),warr[2],warr[3]);
  771.     }
  772. }
  773.  
  774. function processAgentWindow() {
  775.     /* Format Output to Log Window */
  776.     AgentWin.innerHTML = AgentWinInit;
  777.     FOps = "<table id='agnthdr' border='0' cellpadding='1' cellSpacing='1' width='100%'><tr>";
  778.     FOps += "<td width='4%' align='center' style='background-color:activeborder' class='optextb'>";
  779.     FOps += "I/U" + "</td>";
  780.     FOps += "<td width='6%' align='center' style='background-color:activeborder' class='optextb'>";
  781.     FOps += "Status" + "</td>";
  782.     FOps += "<td width='10%' align='center' title='Sort by Agent version' onclick='processSort(0)' style='background-color:activeborder; cursor:hand' class='optextb'>";
  783.     FOps += "Version" + "</td>";
  784.     FOps += "<td width='23%' align='center' title='Sort by Name' onclick='processSort(1)' style='background-color:activeborder; cursor:hand' class='optextb'>";
  785.     FOps += "Name" + "</td>";
  786.     FOps += "<td width='15%' align='center' title='Sort by IP Address' onclick='processSort(2)' style='background-color:activeborder; cursor:hand' class='optextb'>";
  787.     FOps += "IP Address" + "</td>";
  788.     FOps += "<td width='15%' align='center' title='Sort by Domain' onclick='processSort(3)' style='background-color:activeborder; cursor:hand' class='optextb'>";
  789.     FOps += "Domain" + "</td>";
  790.     FOps += "<td width='*' align='center' style='background-color:activeborder' class='optextb'>";
  791.     FOps += "Path" + "</td>";
  792.     FOps += "</tr></table>";
  793.     AgentWin.insertAdjacentHTML("afterBegin",FOps);
  794. }
  795. var AgentObjectArray = new Array();
  796. var AgentCheckBoxObjectArray = new Array();    
  797. var AgentCheckedCount = 0;
  798. function processAgentWindowEntry(cidx,tflag,domname) {
  799.     if ( tflag == "0" ) { // if in Computer table
  800.         var warr = new Array();
  801.         warr = AC_StoreArr[cidx+9].split(" ");
  802.         warr = warr[0].split(";");
  803.         aversion = warr[0];
  804.         aversion = (aversion.length > 15) ? "" : aversion;
  805.     }
  806.     else {
  807.         aversion = "";
  808.     }
  809.     // Determine Domain Array index to get Login Info later
  810.     var deflag = 0;
  811.     var enumdomain = "";
  812.     var pdomain = domname;
  813.     
  814.     if ( tflag == "0" ) {
  815.         if ( AC_StoreArr[cidx+10] != "" ) {
  816.             if ( AC_StoreArr[cidx+10].toLowerCase() != domname.toLowerCase()  ) {
  817.                 deflag = ( domname == "" ) ? 1 : 2;
  818.                 enumdomain = domname;
  819.             }
  820.             domname = AC_StoreArr[cidx+10];
  821.         }
  822.         else if ( domname == "" ) {
  823.            return; // ignore any with no Domain designation in the database and none enumerated
  824.         }
  825.     }
  826.     var  daidx=0;
  827.     for ( var i=0; i<AC_DomainArr.length; i+=UserRecLength ) {
  828.        if ( domname == AC_DomainArr[i] ) {
  829.            daidx = i;
  830.            break;
  831.        }
  832.     }    
  833.     
  834.     aipath = CreateAIPath( ((tflag == "0") ? AC_StoreArr[cidx+0] : EnumeratedServersArr[cidx+1]) );
  835.     var ddom = (tflag == "0") ? domname.toLowerCase() : EnumeratedServersArr[cidx].toLowerCase();
  836.     FOps = "<div id='agentrow" + ELIdx + "' apath='" + aipath + "' pdom='" + pdomain + "' aver='" + aversion + "' ddom='" + ddom +"' cidx='" + cidx + "' daidx='" + daidx +"' tflag='" + tflag;
  837.     if ((ELBgFlg ^= 1) == 0) {
  838.         FOps += "' style='background-color:white;"; 
  839.     }
  840.     else {
  841.         FOps += "' style='background-color:e8e8e8;";
  842.     }
  843.     FOps += "'>"; 
  844.  
  845.     FOps += "<table border='0' cellpadding='1' cellSpacing='1' width='100%'><tr>";
  846.     FOps += "<td width='4%' align='center' class='optext'>";
  847.     FOps += "<input onclick='processAgentCheckClick()' id='agnt" + ELIdx + "' type='checkbox'></td>";
  848.     FOps += "<td width='6%' style='cursor:hand' class='optext' id='astat" + ELIdx + "'>";
  849.     FOps += "</td>";
  850.     FOps += "<td width='10%' class='optext'>";
  851.     FOps += aversion + "</td>";
  852.     FOps += "<td width='23%' style='fontFamily:arial' title='"+((tflag == "0") ? AC_StoreArr[cidx+2] : EnumeratedServersArr[cidx+6])+"' class='optext'>";
  853.     FOps += ((tflag == "0") ? AC_StoreArr[cidx+0] : "<b>"+EnumeratedServersArr[cidx+1]+"</b>") + "</td>";
  854.     FOps += "<td width='15%' style='fontFamily:arial' class='optext'>";
  855.     FOps += ((tflag == "0") ? AC_StoreArr[cidx+5] : "<b>"+EnumeratedServersArr[cidx+2]+"</b>") + "</td>";
  856.     FOps += "<td width='15%' style='fontFamily:arial' class='optext' ";
  857.     if ( deflag == 1 && ShowAllDomain.checked) { FOps += "style='color:orange; cursor:hand' title='Defined in database with this Domain but not found when enumerating servers'"; }    
  858.     else if ( deflag == 2 && ShowAllDomain.checked) { FOps += "style='color:red; cursor:hand' title='Defined in database with this Domain but found in `"+enumdomain+"` when enumerating servers' "; }    
  859.     else if ( tflag != "0" ) { FOps += "style='cursor:hand' title='Not defined in database but found in `"+EnumeratedServersArr[cidx].toUpperCase()+"` when enumerating servers' "; }    
  860.     FOps += ">"+((tflag == "0") ? domname.toLowerCase() : "<b>"+EnumeratedServersArr[cidx].toLowerCase()+"</b>") + "</td>";
  861.     FOps += "<td width='*' style='cursor:hand' title='Click Path to Edit' onclick='processAgentPathClick(" + ELIdx + ")' class='optext' id='apathspec" + ELIdx + "'>";
  862.     FOps += ((tflag == "0") ? aipath : "<b>"+aipath+"</b>") + "</td>";
  863.     FOps += "</tr></table></div>";
  864.     AgentText.insertAdjacentHTML("beforeEnd",FOps);
  865.     AgentObjectArray[ELIdx] = document.all["agentrow"+ELIdx];  
  866.     AgentCheckBoxObjectArray[ELIdx] = document.all["agnt"+ELIdx];  
  867.     ++ELIdx; // bump index count
  868. }
  869. var GlobalAgentPathIndex = 0;
  870. function processAgentPathClick(pindx) {
  871.     if ( GlobalAIP ) return; // exit if busy
  872.     GlobalAIP = true;
  873.     SetButtonState(OKButtonAIP,"0"); // enable
  874.     SetButtonState(CancelButtonAIP,"0");
  875.     GlobalAgentPathIndex = pindx;
  876.     PopUpAI.style.display="";
  877.     SetDefaultPath.checked = "";
  878.     DefaultPathCheckbox.style.display = "";
  879.     AIPath.value = AgentObjectArray[pindx].apath;
  880. }
  881. function processGlobalAgentPath() {
  882.     AgentObjectArray[GlobalAgentPathIndex].apath = AIPath.value;
  883.     document.all["apathspec"+GlobalAgentPathIndex].innerText = AIPath.value;
  884.     GlobalAIP = false;
  885.     PopUpAI.style.display="none";
  886.     if ( SetDefaultPath.checked ) {
  887.         var ndx = AIPath.value.indexOf("\\",2); //"
  888.         var bastrg = AIPath.value.substring(ndx, AIPath.value.length);
  889.         var wstrg = "";
  890.         for ( var i=0; i<AgentObjectArray.length; i++ ) {
  891.            ndx = AgentObjectArray[i].apath.indexOf("\\",2); //"
  892.            wstrg = AgentObjectArray[i].apath.substring(0,ndx);
  893.            wstrg += bastrg;
  894.            AgentObjectArray[i].apath = wstrg;
  895.            document.all["apathspec"+i].innerText = wstrg;
  896.         }  
  897.     }        
  898. }
  899. function processSelect(Pflg) {
  900.     for ( var i=0; i<AgentCheckBoxObjectArray.length; i++ ) {
  901.        AgentCheckBoxObjectArray[i].checked = (Pflg == "1") ? "" : "checked";
  902.     }
  903.     AgentCheckedCount = (Pflg == "1") ? 0 : AgentCheckBoxObjectArray.length;
  904.     if ( AgentCheckedCount == 0 ) {
  905.         SetButtonState(GlobalInstallAgentButton,"1");
  906.     }
  907.     else {
  908.         SetButtonState(GlobalInstallAgentButton,"0");        
  909.     }
  910. }
  911. function processAgentCheckClick() {
  912.     if ( document.all[event.srcElement.id].checked == "" ) {
  913.         --AgentCheckedCount;
  914.     }
  915.     else {
  916.         ++AgentCheckedCount;
  917.     }
  918.     if ( AgentCheckedCount == 0 ) {
  919.         SetButtonState(GlobalInstallAgentButton,"1");
  920.     }
  921.     else {
  922.         SetButtonState(GlobalInstallAgentButton,"0");        
  923.     }
  924. }
  925. var AIndx = 0;
  926. var GlobalAIP = false;
  927. var AgentCancel = false;
  928. function processGlobalInstallAgentButton() {       
  929.     if ( AgentCheckedCount == 0 ) {
  930.         alert("Please select one or more servers/workstations where you want the Agent installed!");
  931.     }
  932.     else if ( confirm("Are you sure you want to install the Agent on the selected servers/workstations?\n-Have you specified Administrator 'Logon' credentials?") ) {
  933.         // Determine Count of Checked Servers Not Currently in the Database
  934.         for ( var i=0, acount=0; i<AgentCheckBoxObjectArray.length; i++ ) {
  935.             if ( AgentCheckBoxObjectArray[i].checked && AgentObjectArray[i].tflag == "1" ) {    
  936.                ++acount; 
  937.             }
  938.         }
  939.         if ( acount > (LicenseMax-LicenseCur) ) {
  940.             alert("You have selected "+acount+" new servers/workstations to install the Agent.\nHowever, you only have "+(LicenseMax-LicenseCur)+" license(s) available for new servers/workstations!\n-Adjust the number of new servers/workstations selected");
  941.             return;
  942.         }
  943.         AIndx = 0;
  944.         GlobalAIP = true;
  945.         AgentCancel = false;
  946.         SetButtonState(GlobalInstallAgentButton,"1"); // disable
  947.         SetButtonState(AgentCancelButton,"0"); // enable
  948.         SetButtonState(AgentDoneButton,"1"); // disable
  949.         processGlobalInstallAgentContinue();    
  950.     }
  951. }
  952.  
  953. var rescol = "white";
  954. function processGlobalInstallAgentContinue() {
  955.     for ( ; AIndx < AgentCheckBoxObjectArray.length && !AgentCancel; ++AIndx ) {
  956.         if ( AgentCheckBoxObjectArray[AIndx].checked ) {    
  957.             var Cindx = parseInt( AgentObjectArray[AIndx].cidx,10 );
  958.             var DAindex = parseInt( AgentObjectArray[AIndx].daidx,10 );
  959.             var tflag = AgentObjectArray[AIndx].tflag;
  960.             
  961.             AI_arg = AgentObjectArray[AIndx].apath+"~"+((tflag == "0") ? AC_StoreArr[Cindx+5] : EnumeratedServersArr[Cindx+2])+"~";
  962.             if ( AC_DomainArr.length == 0 ) {
  963.                 AI_arg += logon_username.value+"~"+logon_password.value+"~"+logon_domainname.value+"~";
  964.             }
  965.             else {
  966.                 // Look for match on server/workstation name and a Domain name which is also a 'stand-alone'
  967.                 for ( var i=0; i<AC_DomainArr.length; i+=UserRecLength ) {
  968.                     if ( AC_DomainArr[i+5] == "3" && AC_DomainArr[i].toLowerCase() == ((tflag == "0") ? AC_StoreArr[Cindx] : EnumeratedServersArr[Cindx+1]).toLowerCase() ) {
  969.                         AI_arg += AC_DomainArr[i+4]+"~" +AC_DomainArr[i+3]+"~"+AC_DomainArr[i]+"~";
  970.                          break;
  971.                      } 
  972.                 }        
  973.                 if ( i >= AC_DomainArr.length ) {
  974.                     // Check if any credentials provided for matched Doamin
  975.                     if ( AC_DomainArr[DAindex+4].length > 0 ) {
  976.                         AI_arg += AC_DomainArr[DAindex+4]+"~"+AC_DomainArr[DAindex+3]+"~";
  977.                     }
  978.                     else { // otherwise use <All> credentials if any for the matched Domain
  979.                         AI_arg += AC_DomainArr[4]+"~"+AC_DomainArr[3]+"~";
  980.                     }
  981.                     AI_arg += ( (DAindex == 0) ? "" : AC_DomainArr[DAindex] )+"~";
  982.                 }
  983.             }
  984.             // Expand the string to force it to be compressed (and by implication, 'encypted')
  985.             while ( AI_arg.length < 512 ) {
  986.                AI_arg += AI_arg;
  987.          }
  988.          
  989.             if ( RpmCC_AC.AgentInstall( AI_arg ) ) {
  990.                 var Lstatstrg = "<img src='images/reset.gif' align='absmiddle' height='15' title='Unable to initiate the Agent Install/Update' width='15'>";
  991.                 document.all["astat"+AIndx].innerHTML = Lstatstrg;                
  992.             }    
  993.             else { // waiting for OperationCompleteEvent
  994.                 rescol = ((AIndx % 2) == 0 ) ? "e8e8e8" : "white";
  995.                 AgentObjectArray[AIndx].style.backgroundColor = "scrollbar";
  996.                   SetCursor("wait");
  997.                   top.banner.processStartComm();
  998.                 top.Rstatus.Pstat("Agent Install/Update proceeding on "+((tflag == "0") ? AC_StoreArr[Cindx] : EnumeratedServersArr[Cindx+1]),true);
  999.                 return;
  1000.             }
  1001.         }
  1002.     }
  1003.     GlobalAIP = false;
  1004.     SetButtonState(GlobalInstallAgentButton,"0");
  1005.     SetButtonState(AgentCancelButton,"1");
  1006.     SetButtonState(AgentDoneButton,"0"); // enable
  1007.     if ( AgentCancel ) {
  1008.         alert("Agent Install/Update Canceled. Consult the Status column for results of those completed!");
  1009.     }
  1010.     else {
  1011.         alert("Done Agent Install/Update. Consult the Status column for results!\nHover with mouse over status icon for status text.");
  1012.     }
  1013.     top.Rstatus.Pstat("Done");
  1014. }
  1015. function processAgentCancelButton() {
  1016.     AgentCancel = true;
  1017.     SetButtonState(AgentCancelButton,"1");
  1018. }
  1019.  
  1020. function processResetButton() {
  1021.     IPLookupButton.style.display = "none";
  1022.     AdminGroupButton.style.display = "";
  1023.     ConfigAlertButton.style.display = "";
  1024.     // if Edit mode just finish up Edit without updating store
  1025.     if ( CMode == "Edit" ) {
  1026.         processEditComplete(true);
  1027.         return;
  1028.     }
  1029.     SetButtonState(VerifyButton,"1");
  1030.  
  1031.     var saveMode = CMode;
  1032.     PopUpDiv.style.display="none";
  1033.     AddServicesFlag = 0; // reset 
  1034.     ELogWinMain.style.display="none";
  1035.     MonServerRow0.style.visibility = "hidden";
  1036.     MonServerRow1.style.visibility = "hidden";
  1037.     viewToggle = 0;
  1038.     MonServerButton.style.display = "none";
  1039.     
  1040.     processResetDone();
  1041.     if ( saveMode == "New" ) {
  1042.         allGrpSelected = true; 
  1043.       processLookupButton();
  1044.       }
  1045.     SetCursor("auto");
  1046.       top.banner.processStopCommX();
  1047. }
  1048.  
  1049. function processUpdateButton() {
  1050.     /* get input which is validated when first entered */
  1051.     if ( processServiceSelectGet() == false ) // if invalid input
  1052.         return;
  1053.     processServiceSelectPut();
  1054.     // get cuurent selected Service parameters
  1055.     CName = AC_Name.value; 
  1056.     CGrpID = getGroupID(AC_Group.value,AC_GrpStore);
  1057.     CPswd = AC_Pswd.value;
  1058.     CDesc = AC_Desc.value;
  1059.     var darr = new Array();
  1060.     darr = CDesc.split("'");
  1061.     CDesc = darr.join("`");
  1062.     CDesc += " DOMAIN="+AC_DomainNSel.options[AC_DomainNSel.selectedIndex].value;
  1063.     
  1064.     var SNMPflag = (AC_SNMPEnabled.checked) ? "1" : "0";
  1065.     var MIBObjects = createMIBObjectArray();
  1066.     if (SNMPflag == "1" && MIBObjects == "") { // if no MIB Objects selected
  1067.         top.Rstatus.Pstat("Please select one or more MIB Objects, or disable SNMP",true);        
  1068.         alert("You have enabled SNMP but have not selected at least one MIB Object to include for monitoring!\n\nPlease select one or more MIB Objects or disable SNMP monitoring!");        
  1069.         processGeneralClick(SNMPTab);
  1070.         return;
  1071.     }
  1072.     if ( SNMPflag == "0" ) {
  1073.         MIBObjects = ""; 
  1074.         for ( var i=0; i<MIBObjectArr.length; i++ ) {
  1075.             MIBObjectCheckArr[i] = "0";   
  1076.         }    
  1077.         AC_MIBSel.length = 0;
  1078.     }
  1079.     
  1080.     CDesc += " SNMPINFO="+SNMPflag+":!"+MIBObjects+":!"+AC_ReadComm.value+":!"+AC_SNMPPort.value+":!"+AC_Collection.value;
  1081.     
  1082.     AC_DomainN.value = AC_DomainNSel.options[AC_DomainNSel.selectedIndex].value;
  1083.     CIP = AC_IPAddr.value;
  1084.     CPort = AC_Port.value;
  1085.     CSrvID = getServerID(AC_Server.value);
  1086.     if (CName.length == 0) { // if no name entered
  1087.         top.Rstatus.Pstat("Please enter a name",true);        
  1088.         alert("Please enter a name");        
  1089.         AC_Name.focus();
  1090.     }
  1091.     else if (CPswd != AC_VPswd.value) {
  1092.         top.Rstatus.Pstat("Verify Password Does Not Match Password, please reenter both",true);
  1093.         alert("Verify Password Does Not Match Password, please reenter both");
  1094.         AC_Pswd.focus();    
  1095.     }        
  1096.     else {
  1097.         if ( CPswd != "" ) { 
  1098.             if ( !confirm("Are you sure you want to define an Agent Password?\n -You will have to define this same Password at\nthe Agent, which it will use to authenticate and\nsuccessfully connect to the MonitorIT Server.\n\nPress OK to accept the Password!\nPress Cancel to go back to edit!") ) {
  1099.                 AC_Pswd.focus();    
  1100.                 return;
  1101.             }
  1102.         }  
  1103.         /* inhibit Verify, Update and Reset Buttons now */
  1104.         SetButtonState(CUpdateButton,"1");
  1105.         SetButtonState(CResetButton,"1");
  1106.         SetButtonState(VerifyButton,"1");
  1107.         SetButtonState(InstallAgentButton,"1");
  1108.         AdminGroupButton.style.display = "";
  1109.         ConfigAlertButton.style.display = "";
  1110.     
  1111.         /* Determine if CMode is "New" or "Edit" and send data to DataBase Server appropriately */
  1112.         if (CMode == "New") {
  1113.             // Initialize additional "New" parameters
  1114.             COSver = "Unknown"; CMonStart = "";    CMonStop = ""; CMonSched = 251658496; CDlvStart = ""; CDlvStop = ""; CDlvSched = 16843008;
  1115.             rstat = RpmCC_AC.ComputerAdd(CName,CGrpID,CSrvID,CPswd,CDesc,CIP,CPort,COSver,CMonStart,CMonStop,CMonSched,CDlvStart,CDlvStop,CDlvSched);
  1116.             LastNew = CName;
  1117.         }
  1118.         else { // "Edit"
  1119.             OrigCName = AC_NameSel.options[CurSelectIdx].text; // Selected Computer Name is Original Computer Name
  1120.             rstat = RpmCC_AC.ComputerReplace(OrigCName,CName,CGrpID,CSrvID,CPswd,CDesc,CIP,CPort);
  1121.         }
  1122.     
  1123.         if ( rstat ) { // if unable to initiate request        
  1124.             top.Rstatus.Pstat("Unable to start the UPDATE request",true);
  1125.             processResetButton();
  1126.         }
  1127.         else { // waiting for OperationCompleteEvent
  1128.             ++ignoreDBChangeEvent;
  1129.             top.Rstatus.Pstat("One moment while UPDATE for '"+AC_Name.value+"' completes");
  1130.         }
  1131.     }
  1132. }
  1133.  
  1134. function processDeleteButton() {
  1135.     CMode = "Delete"; // set mode of operation
  1136.     /* ask user to confirm delete */
  1137.     if ( confirm("Are you sure you want to delete: " + AC_Name.value + " ?") ) {
  1138.         /* inhibit Edit, Delete, and Reset Buttons now */
  1139.         SetButtonState(CResetButton,"1");
  1140.         SetButtonState(CEditButton,"1");
  1141.         SetButtonState(CDupButton,"1");
  1142.         SetButtonState(CDeleteButton,"1");
  1143.         SetButtonState(WMButton,"1");
  1144.     
  1145.         /* send DELETE request to DataBase Server */
  1146.         if ( RpmCC_AC.ComputerDelete(AC_Name.value) ) {
  1147.             top.Rstatus.Pstat("Unable to start the DELETE request",true);
  1148.             processResetButton();
  1149.         }
  1150.         else { // waiting for OperationCompleteEvent
  1151.             ++ignoreDBChangeEvent;
  1152.             SetCursor("wait");
  1153.             top.banner.processStartComm();
  1154.             top.Rstatus.Pstat("Moment please.  Deleting a server/computer may take several minutes");
  1155.         }
  1156.     }
  1157. }
  1158.  
  1159. function commonNew_Edit() { //Common processing for New and Edit
  1160.     /* enable input fields */
  1161.     AC_GroupSel.className = "";
  1162.     AC_Pswd.className = "";
  1163.     AC_VPswd.className = "";
  1164.     AC_Desc.className = "";    
  1165.     AC_IPAddr.className = "";    
  1166.     AC_Port.className = "";
  1167.     AC_Server.className = "";
  1168.     AC_DomainNSel.className = "";
  1169.  
  1170.     /* enable and disable appropriate buttons */
  1171.     SetButtonState(CNewButton,"1");
  1172.     SetButtonState(CEditButton,"1");
  1173.     SetButtonState(CDupButton,"1");
  1174.     SetButtonState(CDeleteButton,"1");
  1175.     SetButtonState(WMButton,"1");
  1176.     SetButtonState(CUpdateButton,"0");
  1177.     SetButtonState(CResetButton,"0");
  1178.     SetButtonState(LogonButtonOnTab,"0");
  1179.     SetButtonState(InstallAgentButton,"0");
  1180.     IAText.innerText =  ( AC_OSver.value == "" || AC_OSver.value == "Unknown" ) ? "Install" : "Update";
  1181.  
  1182.     /* enable appropriate Computer and Group Name fields */
  1183.     AC_Name.style.display = "";
  1184.     AC_NameSel.style.display = "none";
  1185.     AC_Name.focus();
  1186.     AC_Group.style.display = "none";
  1187.     AC_GroupSel.style.display = "";
  1188.     AC_Server.style.display = "none";
  1189.     if ( viewToggle == 1 ) {
  1190.         AC_ServerSel.style.display = "";
  1191.     }
  1192.  
  1193.     AC_SNMPEnabled.className = "";
  1194.     AC_SNMPEnabled.disabled = ""; 
  1195.     if ( AC_SNMPEnabled.checked ) {
  1196.         if ( GotMIBData ) {
  1197.             SetButtonState(MIBObjectButton,"0");
  1198.         }
  1199.         AC_MIBSel.className = ""; 
  1200.         AC_ReadComm.className = ""; 
  1201.         AC_SNMPPort.className = ""; 
  1202.         AC_Collection.className = ""; 
  1203.     }
  1204.  
  1205.     var lth = AC_DomainNSel.length;
  1206.     for (i=0; i < lth; ++i)
  1207.         AC_DomainNSel.remove(0);
  1208.     addElementToSelect(AC_DomainNSel,"");
  1209.     for ( var i=UserRecLength; i<AC_DomainArr.length; i+=UserRecLength ) {
  1210.         if ( AC_DomainArr[i+5] != "3" ) {
  1211.             addDomainElementToSelect(AC_DomainNSel,AC_DomainArr[i]+DtypTxt[parseInt(AC_DomainArr[i+5],10)],AC_DomainArr[i]);
  1212.         }
  1213.     }
  1214.     AC_DomainNSel.selectedIndex = 0;
  1215.     for ( var i=0; i<AC_DomainNSel.length; i++ ) {
  1216.         if ( AC_DomainNSel.options[i].value == AC_DomainN.value ) {
  1217.             AC_DomainNSel.selectedIndex = i;
  1218.             break;
  1219.         } 
  1220.    }        
  1221.     AC_DomainN.style.display = "none";
  1222.     AC_DomainNSel.style.display = "";
  1223.  
  1224.     IPLookupButton.style.display = "";
  1225.     //MonServerButton.style.display = "";
  1226.     AdminGroupButton.style.display = "none";
  1227.     ConfigAlertButton.style.display = "none";
  1228.  
  1229.     /* enable checkboxes */
  1230.     genchk.disabled = genchk.className = "";
  1231.     processServiceSelectPut(); 
  1232.     ServiceSelect.className = "";
  1233.  
  1234.     AC_GroupSel.multiple = "";
  1235.     AC_GroupSel.size = "1";
  1236.     allDeselectGroup(AC_GroupSel); // deselect all in Group
  1237. }
  1238. function addDomainElementToSelect(SelectObj,text,value) {
  1239.     var el = document.createElement("OPTION");
  1240.     el.text = text;
  1241.     el.value = value;
  1242.     SelectObj.options.add(el);
  1243.     return el;
  1244. }
  1245. // Enable IP Address Lookup Window Pop-up Window
  1246. function processIPLookupButton() {
  1247.     SetButtonState(OKButtonDL,"0"); // enable
  1248.     SetButtonState(CancelButtonDL,"0");
  1249.     SetButtonState(CUpdateButton,"1");
  1250.     SetButtonState(CResetButton,"1");
  1251.     SetButtonState(DiscoveryButton,"1");  
  1252.     SetButtonState(VerifyButton,"1");  
  1253.     SetButtonState(InstallAgentButton,"1");
  1254.     SetButtonState(ManageAgentsButton,"1");
  1255.     AC_DomainNSel.style.display="none";
  1256.     PopUpDomain.style.display="";
  1257.     DomainToLookup.value = AC_Name.value; // populate with Computer Name
  1258. }
  1259. function processIPLookupCancelButton() {
  1260.     SetButtonState(CUpdateButton,"0");
  1261.     SetButtonState(CResetButton,"0");
  1262.     SetButtonState(VerifyButton,"0");  
  1263.     SetButtonState(InstallAgentButton,"0");
  1264.     SetButtonState(ManageAgentsButton,"0");
  1265.     if ( CMode == "New" ) {
  1266.         SetButtonState(DiscoveryButton,"0");
  1267.     }
  1268.     PopUpDomain.style.display="none"; // disable pop-up
  1269.     AC_DomainNSel.style.display="";    
  1270. }    
  1271.     
  1272. function processIPLookupOKButton() {
  1273.     SetButtonState(OKButtonDL,"1"); // disable
  1274.     SetButtonState(CancelButtonDL,"1");
  1275.     AC_IPAddr.value = RpmMIL.ResolveNameToIPAddr(DomainToLookup.value);    
  1276.     processIPLookupCancelButton(); // reset
  1277. }
  1278.  
  1279.  
  1280. /* Process Combo Computer Name Change Event */
  1281. function processComputerName() {
  1282.     Nobj = AC_NameSel; // get object
  1283.     for (i=0; i < Nobj.length; ++i) {
  1284.         if ( Nobj.options[i].selected ) {
  1285.             CurSelectIdx = i;
  1286.             populateInput(ComputerRecLength*i);
  1287.             break;
  1288.         }
  1289.     }
  1290. }
  1291.  
  1292. /* Process Combo Group Name Change Event */
  1293. function processGroupName() {
  1294.     Nobj = AC_GroupSel; // get object
  1295.     if (Nobj.multiple == "") { // single mode 
  1296.         for (i=0; i < Nobj.length; ++i) {
  1297.             if ( Nobj.options[i].selected ) {
  1298.                 GrpSelectIdx = i;
  1299.                 // Synchronize Group name field with Combo name field
  1300.                 AC_Group.value = Nobj.options[i].text;     
  1301.                 break;
  1302.             }
  1303.         }
  1304.     }
  1305. }
  1306.  
  1307. var CurrentSelectedComputer = 0;
  1308. function populateInput(idx) {
  1309.     CurrentSelectedComputer = idx;
  1310.     // Synchronize name field with Combo name field
  1311.     AC_Name.value = AC_StoreArr[idx+0]; 
  1312.     // Set rest of input fields
  1313.     AC_Group.value = getGroupName(AC_StoreArr[idx+1],AC_GroupSel,AC_GrpStore);
  1314.     AC_Desc.value = AC_StoreArr[idx+2];
  1315.     AC_Pswd.value = AC_StoreArr[idx+3];
  1316.     AC_VPswd.value = AC_Pswd.value;
  1317.     AC_OSver.value = AC_StoreArr[idx+4];
  1318.     AC_IPAddr.value = AC_StoreArr[idx+5];
  1319.     AC_Port.value = AC_StoreArr[idx+6];
  1320.     AC_Server.value = getServerName(AC_StoreArr[idx+8]);
  1321.     AC_AgentVer.value = AC_StoreArr[idx+9];
  1322.     AC_DomainN.value = AC_StoreArr[idx+10];
  1323.  
  1324.     var sarr = new Array();
  1325.     sarr = AC_StoreArr[idx+11].split(":!");
  1326.     AC_SNMPEnabled.checked = (sarr[0] =="1") ? "checked" : "";
  1327.     //Reset Object checked array
  1328.     for ( var i=0; i<MIBObjectArr.length; i++ ) {
  1329.         MIBObjectCheckArr[i] = "0";      
  1330.     }
  1331.     if ( sarr.length >= 5 ) {
  1332.         AC_ReadComm.value = sarr[2];
  1333.         AC_SNMPPort.value = sarr[3];
  1334.         AC_Collection.value = sarr[4];
  1335.         
  1336.         var sarr1 = new Array();
  1337.         sarr1 = sarr[1].split(";!");
  1338.         // Now set the appropriate ones
  1339.         for ( var i=0; i<sarr1.length; i++ ) {
  1340.             for ( var j=1; j<MIBObjectArr.length-1; j++ ) {
  1341.                 if ( sarr1[i] == MIBObjectArr[j] ) {   
  1342.                       MIBObjectCheckArr[j] = "1";
  1343.                       break;
  1344.                   }
  1345.               }
  1346.         }
  1347.     }
  1348.     if ( CurSelTab == "SNMPTab" ) {
  1349.         displayMIBObjectChoices();
  1350.         AC_MIBSel.style.visibility="visible";
  1351.     }
  1352.     else {
  1353.         AC_MIBSel.style.visibility="hidden";
  1354.     }
  1355.     
  1356.     rqstin.style.visibility="hidden";
  1357.     respin.style.visibility="hidden";
  1358.     sqlsrv.style.visibility="hidden";
  1359.     sqlusr.style.visibility="hidden";
  1360.     var warr = new Array();
  1361.     var warr1 = new Array();
  1362.     var pv = 0;
  1363.     resetServiceFields(); // initialize Service fields
  1364.     var cid = AC_StoreArr[idx+7]; // Computer ID
  1365.     var ssi = ServiceTypeCount; // preset for last Service 
  1366.     for ( var i=0, j=-1; i<AC_ServicesStoreArr.length; i+=ServicesRecLength ) {
  1367.         if ( AC_ServicesStoreArr[i] == cid ) { // match on Computer ID
  1368.             if ( AC_ServicesStoreArr[i+1] == "" ) { // if null entry
  1369.                 continue; // loop to next
  1370.             }
  1371.             warr = AC_ServicesStoreArr[i+1].split("~"); // get Services Record parameters
  1372.           genchk.checked = "checked";
  1373.           gento.value = warr[4];
  1374.           genret.value = warr[5];
  1375.           if ( (pv = parseInt(warr[6],10)) > 0x10000 ) {
  1376.               genport.value = "" + (pv-0x10000);
  1377.               securechk.checked = "checked";                     
  1378.             }
  1379.             else {
  1380.               genport.value = warr[6];
  1381.               securechk.checked = "";                     
  1382.             }      
  1383.           genname.value = warr[12];
  1384.            genrqst.value = warr[13];
  1385.              genresp.value = warr[14];
  1386.  
  1387.             if ( warr[3] == "AGENT" ) { continue; }
  1388.             else if ( warr[3] == "PING" ) { j = 0; }
  1389.             else if ( warr[3] == "HTTP" ) { 
  1390.                 j = 1; 
  1391.                 rqstin.style.visibility="visible"; 
  1392.                 genname.value = warr[14]; 
  1393.                 respin.style.visibility="visible";
  1394.                 // parse out the leading "/"
  1395.                  genresp.value = warr[13].substring(1,warr[13].length);
  1396.             }
  1397.             else if ( warr[3] == "FTP" ) { j = 2; }
  1398.             else if ( warr[3] == "SMTP" ) { j = 3; }
  1399.             else if ( warr[3] == "POP" ) { j = 4; }
  1400.             else if ( warr[3] == "DNS" ) { j = 5; rqstin.style.visibility="visible"; }
  1401.             else if ( warr[3] == "USER" ) { j = 6; rqstin.style.visibility="visible"; respin.style.visibility="visible";}
  1402.             else if ( warr[3] == "SQLCONNECT" ) { 
  1403.                 j = 7; 
  1404.                 rqstin.style.visibility="visible"; respin.style.visibility="visible"; 
  1405.                 sqlsrv.style.visibility="visible"; sqlusr.style.visibility="visible";
  1406.                 warr1 = genrqst.value.split(",");
  1407.               genrqst.value = warr1[3];
  1408.               genresp.value = warr1[2];
  1409.                sqlsrvnme.value = warr1[0];
  1410.               sqlusrnme.value = warr1[1];
  1411.             }
  1412.             else if ( warr[3] == "SNMP" ) { 
  1413.                 j = 8; 
  1414.                 rqstin.style.visibility="visible"; respin.style.visibility="visible"; 
  1415.                 warr1 = genrqst.value.split(",");
  1416.               genrqst.value = warr1[0];
  1417.               genresp.value = warr1[1];
  1418.                sqlsrvnme.value = (warr1.length >= 4) ? warr1[3] : "";
  1419.                sqlusrnme.value = (warr1.length >= 5) ? warr1[4] : "";
  1420.             }
  1421.             else if ( warr[3] == "TELNET" ) { j = 9; }
  1422.             else if ( warr[3] == "ORACLE" ) { 
  1423.                 j = 10; 
  1424.                 rqstin.style.visibility="visible"; respin.style.visibility="visible"; 
  1425.                 sqlsrv.style.visibility="visible"; sqlusr.style.visibility="visible";
  1426.                 warr1 = genrqst.value.split(",");
  1427.               genrqst.value = warr1[3];
  1428.               genresp.value = warr1[2];
  1429.                sqlsrvnme.value = warr1[0];
  1430.               sqlusrnme.value = warr1[1];
  1431.             }
  1432.             else if ( warr[3] == "L_NOTES" ) { 
  1433.                 j = 11; 
  1434.                 rqstin.style.visibility="visible"; 
  1435.                 respin.style.visibility="visible";
  1436.             }
  1437.             prevServiceSelectIndex = j;
  1438.             processServiceSelectGet(); 
  1439.             if ( j < ssi ) {
  1440.                 ssi = ServiceSelect.selectedIndex = j; // set the selected one
  1441.             }
  1442.         }
  1443.     }
  1444.     if ( j == -1 ) { // if no services, default to show PING
  1445.         ServiceSelect.selectedIndex = 0; // set the selected one   
  1446.     }
  1447.     processServiceSelectPut(); // make sure all required fields are visible
  1448.     if ( AC_OSver.value == "" || AC_OSver.value == "Unknown" ) {
  1449.         IAText.innerText =  "Install";
  1450.         SetButtonState(HWInfoButton,"1");
  1451.     }
  1452.     else {
  1453.         IAText.innerText =  "Update";
  1454.         SetButtonState(HWInfoButton,"0");
  1455.     }
  1456. }
  1457.  
  1458. function updateStore(idx) {
  1459.     AC_NameSel.options[idx].text = AC_Name.value; // get name in case edited
  1460.     si = ComputerRecLength * idx; // index into Store for correct entry
  1461.     AC_StoreArr[si+0] = AC_Name.value;
  1462.     AC_StoreArr[si+1] = getGroupID(AC_Group.value,AC_GrpStore);
  1463.     AC_StoreArr[si+2] = (AC_Desc.value.length == 0) ? "" : AC_Desc.value; 
  1464.     AC_StoreArr[si+3] = (AC_Pswd.value.length == 0) ? "" : AC_Pswd.value;
  1465.     AC_StoreArr[si+4] = (AC_OSver.value.length == 0) ? "" : AC_OSver.value;
  1466.     AC_StoreArr[si+5] = (AC_IPAddr.value.length == 0) ? "" : AC_IPAddr.value;
  1467.     AC_StoreArr[si+6] = (AC_Port.value.length == 0) ? "" : AC_Port.value;
  1468.     AC_StoreArr[si+8] = getServerID(AC_Server.value);
  1469.     AC_StoreArr[si+9] = (AC_AgentVer.value.length == 0) ? "" : AC_AgentVer.value;
  1470.     AC_StoreArr[si+10] = AC_DomainNSel.options[AC_DomainNSel.selectedIndex].value;
  1471.     var SNMPflag = (AC_SNMPEnabled.checked) ? "1" : "0";
  1472.     var MIBObjects = createMIBObjectArray();
  1473.     AC_StoreArr[si+11] = SNMPflag+":!"+MIBObjects+":!"+AC_ReadComm.value+":!"+AC_SNMPPort.value+":!"+AC_Collection.value;
  1474.     
  1475. }
  1476.  
  1477. /* Process Computer OP Complete Event */
  1478. function processComputerOpComplete() {
  1479. var SAstrg = null;
  1480. var warr = new Array();
  1481.  
  1482.     if (CMode == "Lookup") {
  1483.         if (LupRecCount == 0) { // check if any records found
  1484.             top.Rstatus.Pstat("No record matches found for LOOKUP request",true);    
  1485.             processResetButton(); // reset
  1486.             SetButtonState(CEditButton,"1");
  1487.             SetButtonState(CDupButton,"1");
  1488.             SetButtonState(CDeleteButton,"1");
  1489.         }
  1490.         else {    
  1491.             ServicesRecCount = 0; // reset count
  1492.             rstat = RpmCC_AC.ServicesLookup("","","ComputerID,ID DESC");    
  1493.             if ( rstat ) { // if unable to initiate request        
  1494.                 top.Rstatus.Pstat("Unable to start the Services LOOKUP request",true);
  1495.                 processResetButton();    
  1496.             }
  1497.             else { // waiting for OperationCompleteEvent
  1498.                 top.Rstatus.Pstat("One moment while Services LOOKUP request completes");
  1499.             }
  1500.         }
  1501.     }
  1502.     
  1503.     else if (CMode == "Lookup_DiscoveryAdd") {
  1504.         processAddServicesContinue();
  1505.     }
  1506.     
  1507.     else if (CMode == "Lookup_ManageAgent") {
  1508.         if ( ShowAllDomain.checked ) {
  1509.             var filter = processGetDomainAndFilterSpec();
  1510.             if ( filter == "" ) {
  1511.                 processManageAgentContinue();   
  1512.             }
  1513.             else {
  1514.                 top.Rstatus.Pstat("Searching Windows Domain/Workgroup-"+CurrentDomainEnumerated);
  1515.                 MomText.innerHTML = "Searching Windows Domain/Workgroup-<br><b>'"+CurrentDomainEnumerated+"'</b><br>Total Found - <b>0</b>";
  1516.                 RpmCC_AC.GetEnumeratedServers(filter); // go enumerate servers/workstations
  1517.             }
  1518.         }
  1519.         else {
  1520.             processManageAgentContinue();   
  1521.         }
  1522.     }
  1523.  
  1524.     else if (CMode == "Edit") {
  1525.         var idx = ComputerRecLength*CurSelectIdx; // index to computer record beig edited
  1526.         ServEditCID = AC_StoreArr[idx+7]; // Computer ID being edited
  1527.         
  1528.         // Find index into Store for the Services for this Computer
  1529.         for ( var i=0; i<AC_ServicesStoreArr.length; i+=ServicesRecLength ) { 
  1530.             if ( AC_ServicesStoreArr[i] == ServEditCID ) { // match on Computer ID
  1531.                 break; // if found
  1532.             }
  1533.         }
  1534.         if ( i >= AC_ServicesStoreArr.length ) { // if not found
  1535.             var j = i;
  1536.            do { // create a null set of service entries for this Comp ID
  1537.                 AC_ServicesStoreArr[j++] = ServEditCID; // Computer ID
  1538.                  AC_ServicesStoreArr[j++] = "";
  1539.                 ++ServicesRecCount; // bump record counter
  1540.             } while ( (ServicesRecCount % ServiceTypeCount) != 0 )
  1541.         }
  1542.         // Start with Update to PING Service, then exit; ServiceOpComplete handles the rest
  1543.         ServStorIdx = i; // set index to start of Service Records for this Computer
  1544.         ServEditCount = 0; // initialize count
  1545.         //RpmCC_AC.StartStopServicesCheck("0"); // Stop Service Check Threads
  1546.         //ServicesCheckingStopped = true;
  1547.         processServiceEditUpdate("PING",tpingchk,tpingto,tpingret,"","","","","");
  1548.     }    
  1549.  
  1550.     else if (CMode == "Delete") {
  1551.         var idx = ComputerRecLength*CurSelectIdx; // index to computer record to be deleted
  1552.         CompDeleteID = AC_StoreArr[idx+7]; // Computer ID
  1553.         /* Remove computer entry from the Storage */
  1554.         for (i=idx+ComputerRecLength; i < AC_StoreArr.length; ++i, ++idx) {
  1555.             AC_StoreArr[idx] = AC_StoreArr[i];
  1556.         }
  1557.         AC_StoreArr.length -= ComputerRecLength;
  1558.         AC_NameSel.remove(CurSelectIdx);
  1559.     
  1560.         // Now delete the Services record from Store
  1561.         var warr = new Array();
  1562.         // Find index into Store for the Services for this Computer
  1563.         var ServicesIncr = ServiceTypeCount * ServicesRecLength; 
  1564.         for ( var i=0; i<AC_ServicesStoreArr.length; i+=ServicesIncr ) {
  1565.             if ( AC_ServicesStoreArr[i] == CompDeleteID ) {
  1566.                 for (var j=i+ServicesIncr; j < AC_ServicesStoreArr.length; ++i, ++j) {
  1567.                     AC_ServicesStoreArr[i] = AC_ServicesStoreArr[j];
  1568.                 }
  1569.                 AC_ServicesStoreArr.length -= ServicesIncr;
  1570.                 break;
  1571.             }
  1572.         }
  1573.         processDeleteComplete(); // finish up Delete 
  1574.     }
  1575.     
  1576.     else { // Cmode New.  Should not come here; See processComputerAddOpComplete()
  1577.         /* Reset for next */
  1578.         processResetButton();
  1579.     }
  1580. }
  1581.  
  1582. // Edit Complete Wrap-up
  1583. function processEditComplete() {
  1584.       SetCursor("auto");
  1585.     if ( arguments.length == 0 ) {
  1586.         /* update the Storage if not Edit reset */
  1587.         updateStore(CurSelectIdx);
  1588.     }
  1589.     else { // Edit reset, disable Update and Verify button
  1590.         SetButtonState(VerifyButton,"1");
  1591.         SetButtonState(CUpdateButton,"1");
  1592.         populateInput(ComputerRecLength*CurSelectIdx);
  1593.     }
  1594.     if ( ServiceThreadToggleRequired ) {
  1595.         ServiceThreadToggleRequired = false; // reset
  1596.     }
  1597.     processResetDone();
  1598. }
  1599. function processResetDone() {
  1600.     /* enable Edit, Delete, and Reset Buttons now */
  1601.     SetButtonState(CResetButton,"1");
  1602.     SetButtonState(CUpdateButton,"1");
  1603.     SetButtonState(CEditButton,"0");
  1604.     SetButtonState(CDupButton,"0");
  1605.     SetButtonState(CDeleteButton,"0");
  1606.     SetButtonState(CNewButton,"0");
  1607.  
  1608.     SetButtonState(DiscoveryButton,"0");
  1609.     SetButtonState(InstallAgentButton,"0");
  1610.     SetButtonState(ManageAgentsButton,"0");
  1611.     SetButtonState(WMButton,"0");
  1612.  
  1613.     SetButtonState(MIBObjectButton,"1");
  1614.     IPLookupButton.style.display = "none";
  1615.  
  1616.     /* enable appropriate Computer and Group Name fields */
  1617.     AC_Name.style.display = "none";
  1618.     AC_NameSel.style.display = "";
  1619.     AC_Group.style.display = "";
  1620.     AC_GroupSel.style.display = "none";
  1621.     AC_Server.style.display = "";
  1622.     AC_ServerSel.style.display = "none";
  1623.     AC_DomainN.style.display = "";
  1624.     AC_DomainNSel.style.display = "none";
  1625.  
  1626.     AC_SNMPEnabled.className = "idis";
  1627.     AC_SNMPEnabled.disabled = "disabled";
  1628.  
  1629.     /* disable checkboxes */
  1630.     genchk.disabled = "disabled";
  1631.     securechk.disabled = "disabled";
  1632.  
  1633.     securechk.className = genchk.className = genport.className = gento.className = "idis";
  1634.     genret.className = genname.className = genrqst.className = genresp.className = "idis";
  1635.     sqlsrvnme.className = sqlusrnme.className = "idis";
  1636.     ServiceSelect.className = "idis";
  1637.     
  1638.     /* Select current Computer Name and give it focus */
  1639.     if ( AC_NameSel.length > 0 ) {
  1640.         AC_NameSel.options[CurSelectIdx].selected = "selected";
  1641.         if ( AC_NameSel.style.visibility != "hidden" ) {
  1642.             AC_NameSel.focus();
  1643.         }
  1644.     }
  1645.  
  1646.     /* enable and disable appropriate input fields */
  1647.     AC_Group.className = "idis";
  1648.     AC_Pswd.className = "idis";
  1649.     AC_VPswd.className = "idis";
  1650.     AC_Desc.className = "idis";    
  1651.     AC_IPAddr.className = "idis";    
  1652.     AC_Port.className = "idis";    
  1653.     AC_Server.className = "idis";    
  1654.     AC_DomainN.className = "idis";    
  1655.     AC_MIBSel.className = "idis"; 
  1656.     AC_SNMPPort.className = "idis";    
  1657.     AC_ReadComm.className = "idis";    
  1658.     AC_Collection.className = "idis"; 
  1659.     CMode = ""; // reset
  1660. }
  1661.  
  1662. // Delete Complete Wrap-up
  1663. function processDeleteComplete() {
  1664.     top.Rstatus.Pstat("Request Completed");
  1665.     SetCursor("auto");
  1666.     top.banner.processStopCommX();
  1667.     if (AC_NameSel.length == 0) { // if no more computers
  1668.         processResetButton();
  1669.         for ( var i=0; i<MIBObjectArr.length; i++ ) {
  1670.             MIBObjectCheckArr[i] = "0";   
  1671.         }    
  1672.         AC_MIBSel.length = 0;
  1673.         AC_SNMPPort.value = "161";
  1674.         AC_ReadComm.value = "public";
  1675.  
  1676.         AC_Name.value = "";
  1677.         AC_Group.value = "";
  1678.         AC_Pswd.value = "";
  1679.         AC_VPswd.value = "";
  1680.         AC_Desc.value = "";    
  1681.         AC_IPAddr.value = "";
  1682.         AC_Server.value = "";
  1683.         AC_DomainN.value = "";    
  1684.         AC_OSver.value = "";    
  1685.         AC_AgentVer.value = "";
  1686.         SetButtonState(CDeleteButton,"1");
  1687.         SetButtonState(CEditButton,"1");
  1688.         SetButtonState(CDupButton,"1");
  1689.     }
  1690.     else {
  1691.         CurSelectIdx = 0; // reset select index to 1st entry
  1692.         populateInput(0); // adjust input fields
  1693.  
  1694.         /* Select 1st Computer Name and give it focus */
  1695.         AC_NameSel.options[0].selected = "selected";
  1696.         if ( AC_NameSel.style.visibility != "hidden" ) {
  1697.             AC_NameSel.focus();
  1698.         }
  1699.         
  1700.         /* enable Edit, Delete, and Reset Buttons now */
  1701.         SetButtonState(CDeleteButton,"0");
  1702.         SetButtonState(CEditButton,"0");
  1703.         SetButtonState(CDupButton,"0");
  1704.         SetButtonState(CNewButton,"0");
  1705.         SetButtonState(WMButton,"0");
  1706.     }
  1707. }
  1708.  
  1709.  
  1710. /* Do the Part 2, Services Add */
  1711. function processComputerAddOpComplete(cid) {
  1712.     if ( cid == "" ) {
  1713.         return;
  1714.     }
  1715.     ++TotalComputersAdded; // bump count
  1716.     var cnt = 0; // track count of Services
  1717.     var SAstrg = cid; // init string with Computer ID
  1718.    if ( tpingchk ) {
  1719.        ++cnt; // bump Services count
  1720.        SAstrg += "~~PING" + "~" + tpingto + "~" + tpingret + "~~~~~";
  1721.     }
  1722.     if ( thttpchk ) {
  1723.        ++cnt; // bump Services count
  1724.      SAstrg += "~~HTTP" + "~" + thttpto + "~~" + ((thttpsec) ? ""+(parseInt(thttpport,10) + 0x10000) : thttpport ) + "~~"+thttponpage+"~"+thttplookfor+"~";
  1725.     }
  1726.     if ( tftpchk ) {
  1727.        ++cnt; // bump Services count
  1728.       SAstrg += "~~FTP" + "~" + tftpto + "~~" + ((tftpsec) ? ""+(parseInt(tftpport,10) + 0x10000) : tftpport ) + "~~~~";
  1729.     }
  1730.     if ( tsmtpchk ) {
  1731.        ++cnt; // bump Services count
  1732.       SAstrg += "~~SMTP" + "~" + tsmtpto + "~~" + ((tsmtpsec) ? ""+(parseInt(tsmtpport,10) + 0x10000): tsmtpport ) + "~~~~";
  1733.     }
  1734.     if ( tpopchk ) {
  1735.        ++cnt; // bump Services count
  1736.       SAstrg += "~~POP" + "~" + tpopto + "~~" + ((tpopsec) ? ""+(parseInt(tpopport,10) + 0x10000) : tpopport ) + "~~~~";
  1737.     }
  1738.     if ( tdnschk ) {
  1739.        ++cnt; // bump Services count
  1740.       SAstrg += "~~DNS" + "~" + tdnsto + "~" + tdnsret + "~" + tdnsport + "~" + tdnsname + "~~~";
  1741.     }    
  1742.     if ( tuserchk ) {
  1743.        ++cnt; // bump Services count
  1744.       SAstrg += "~~USER" + "~" + tuserto + "~" + tuserret + "~" + tuserport + "~~" + tuserrqst + "~" + tuserresp + "~1";
  1745.     }    
  1746.     if ( tsqlchk ) {
  1747.        ++cnt; // bump Services count
  1748.       SAstrg += "~~SQLCONNECT" + "~" + tsqlto + "~~~~" + tsqlparms + "~~";
  1749.     }    
  1750.     if ( tsnmpchk ) {
  1751.        ++cnt; // bump Services count
  1752.       SAstrg += "~~SNMP" + "~" + tsnmpto + "~" + tsnmpret + "~0~~" + tsnmpparms + "~~";
  1753.     }    
  1754.     if ( ttelchk ) {
  1755.        ++cnt; // bump Services count
  1756.       SAstrg += "~~TELNET" + "~" + ttelto + "~~" + ((ttelsec) ? ""+(parseInt(ttelport,10) + 0x10000) : ttelport ) + "~~~~";
  1757.     }    
  1758.     if ( toraclechk ) {
  1759.        ++cnt; // bump Services count
  1760.       SAstrg += "~~ORACLE" + "~" + toracleto + "~~~~" + toracleparms + "~~";
  1761.     }    
  1762.     if ( tlnoteschk ) {
  1763.        ++cnt; // bump Services count
  1764.       SAstrg += "~~L_NOTES" + "~" + tlnotesto + "~" + tlnotesret + "~" + tlnotesport + "~~" + tlnotesrqst + "~" + tlnotesresp + "~1";
  1765.     }    
  1766.     if ( cnt > 0 ) { // if some Service to add
  1767.         rstat = RpmCC_AC.ServicesAdd(SAstrg);    
  1768.         if ( rstat ) { // if unable to initiate request        
  1769.             top.Rstatus.Pstat("Unable to start the Services UPDATE request",true);
  1770.             processResetButton();
  1771.         }
  1772.         else { // waiting for OperationCompleteEvent
  1773.             top.Rstatus.Pstat("One moment while Services UPDATE for '"+AC_Name.value+"' completes");
  1774.         }
  1775.     }
  1776.     else { // nothing to add; go reset
  1777.         processResetButton();
  1778.         top.Rstatus.Pstat("Done! "+TotalComputersAdded+" computer(s) added");
  1779.         ckQuickStartdone(); // check if QuickStart, and put upmessage box if so
  1780.     }
  1781. }
  1782. function ckQuickStartdone() {
  1783.     if ( top.QuickStartProcessing ) {
  1784.         alert("When finished, exit this 'Administer Servers/Computers' screen and continue with the 'QuickStart' steps screen.  Next, you will define the Watches/Alerts for these newly added Servers/Computers");
  1785.         top.QuickStartProcessing = false;
  1786.     }
  1787. }
  1788.  
  1789. // Prcoess Services Add Operation Complete Event
  1790. function processServicesAddOpComplete(SrvcID) {
  1791.     if ( ServEditMode != "Add" || SrvcID == "" ) {
  1792.         return; // exit and ignore
  1793.     }
  1794.     AC_ServicesStoreArr[FStorIdx] = SrvcID + "~"+ ServAddStrg; // update Store
  1795. }
  1796.  
  1797. // Prcoess Services Operation Complete Event
  1798. function processServicesOpComplete() {
  1799.  
  1800.     if (CMode == "Lookup") {
  1801.         var i = ServicesRecCount * ServicesRecLength;
  1802.        while ( (ServicesRecCount % ServiceTypeCount) != 0 ) { // round out previous
  1803.             AC_ServicesStoreArr[i++] = ServiceCompID; // Computer ID
  1804.              AC_ServicesStoreArr[i++] = "";
  1805.             ++ServicesRecCount; // bump record counter
  1806.         }
  1807.         /* enable combo Computer Name; inhibit one-line input Computer Name */
  1808.         AC_Name.style.display = "none";
  1809.         AC_NameSel.style.display = "";
  1810.         
  1811.         if ( LastNew != "" ) {
  1812.             for (var i=0, j=0; i < AC_StoreArr.length; i+=ComputerRecLength, ++j) {
  1813.                 if ( AC_StoreArr[i] == LastNew ) {
  1814.                     break;
  1815.                 }
  1816.             }
  1817.             if ( i >= AC_StoreArr.length ) {
  1818.                i = j = 0;
  1819.             }
  1820.             /* populate input fields */
  1821.             populateInput(i);    
  1822.             /* Select 1st Computer Name and give it focus */
  1823.             AC_NameSel.options[j].selected = "selected"; 
  1824.             CurSelectIdx = j;
  1825.             LastNew = ""; // reset 
  1826.         }
  1827.         else {   
  1828.             /* populate input fields */
  1829.             populateInput(0);    
  1830.             /* Select 1st Computer Name and give it focus */
  1831.             AC_NameSel.options[0].selected = "selected";
  1832.         }
  1833.         
  1834.         if ( AC_NameSel.style.visibility != "hidden" ) {
  1835.             AC_NameSel.focus();
  1836.         }
  1837.  
  1838.         /* enable Edit, Delete, and Reset Buttons now */
  1839.         SetButtonState(CResetButton,"1");
  1840.         SetButtonState(CNewButton,"0");
  1841.         SetButtonState(CEditButton,"0");
  1842.         SetButtonState(CDupButton,"0");
  1843.         SetButtonState(CDeleteButton,"0");
  1844.         SetButtonState(InstallAgentButton,"0");
  1845.         SetButtonState(LogonButtonOnTab,"0");
  1846.         SetButtonState(ManageAgentsButton,"0");
  1847.         SetButtonState(WMButton,"0");
  1848.         SetButtonState(DiscoveryButton,"0");
  1849.           SetCursor("auto");
  1850.           top.banner.processStopCommX();
  1851.         top.Rstatus.Pstat("Request Completed. Number of Entries Found= "+LupRecCount+"; Current Unique= "+LicenseCur+"; Max Licenses= "+LicenseMax);    
  1852.     //alert("Max="+LicenseMax) 
  1853.         
  1854.     }
  1855.  
  1856.     else if (CMode == "Edit") {
  1857.         switch ( ++ServEditCount ) {
  1858.            case 1 : 
  1859.                 processServiceEditUpdate ("HTTP",thttpchk,thttpto,"",thttpport,"",thttponpage,thttplookfor,thttpsec);
  1860.           break;
  1861.            case 2 : 
  1862.                 processServiceEditUpdate ("FTP",tftpchk,tftpto,"",tftpport,"","","",tftpsec);
  1863.           break;
  1864.            case 3 : 
  1865.                 processServiceEditUpdate ("SMTP",tsmtpchk,tsmtpto,"",tsmtpport,"","","",tsmtpsec);
  1866.           break;
  1867.            case 4 : 
  1868.                 processServiceEditUpdate ("POP",tpopchk,tpopto,"",tpopport,"","","","",tpopsec);
  1869.           break;
  1870.            case 5 : 
  1871.                 processServiceEditUpdate ("DNS",tdnschk,tdnsto,tdnsret,tdnsport,tdnsname,"","","");
  1872.           break;
  1873.           case 6 :
  1874.                 processServiceEditUpdate ("USER",tuserchk,tuserto,tuserret,tuserport,"",tuserrqst,tuserresp,"");
  1875.           break;
  1876.           case 7 :
  1877.                 processServiceEditUpdate ("SQLCONNECT",tsqlchk,tsqlto,"","","",tsqlparms,"","");
  1878.           break;
  1879.           case 8 :
  1880.                 processServiceEditUpdate ("SNMP",tsnmpchk,tsnmpto,tsnmpret,"0","",tsnmpparms,"","");
  1881.           break;
  1882.           case 9 :
  1883.                 processServiceEditUpdate ("TELNET",ttelchk,ttelto,"",ttelport,"","","",ttelsec);
  1884.           break;
  1885.           case 10 :
  1886.                 processServiceEditUpdate ("ORACLE",toraclechk,toracleto,"","","",toracleparms,"","");
  1887.           break;
  1888.           case 11 :
  1889.                 processServiceEditUpdate ("L_NOTES",tlnoteschk,tlnotesto,tlnotesret,tlnotesport,"",tlnotesrqst,tlnotesresp,"");
  1890.           break;
  1891.           case 12 :
  1892.                 processEditComplete(); // finish up Edit
  1893.                 top.Rstatus.Pstat("Request Completed");
  1894.             break;
  1895.         }
  1896.     }
  1897.     
  1898.     else if (CMode == "New") {
  1899.         if ( AddServicesFlag != 0 ) {
  1900.             processAddComputers(); // go set up to Add next computer
  1901.         }
  1902.         else {
  1903.              /* Reset for next */
  1904.             processResetButton();
  1905.             top.Rstatus.Pstat("Done! "+TotalComputersAdded+" server(s) added");
  1906.             ckQuickStartdone(); // check if QuickStart, and put upmessage box if so
  1907.         }
  1908.     }
  1909. }
  1910.  
  1911. // Process the Specified Service Update
  1912. function processServiceEditUpdate(SUtype,SUchk,SUto,SUret,SUport,SUname,SUrqst,SUresp,SUsec) {
  1913. var SAstrg = null;
  1914. var warr = new Array();
  1915.     // Check for secure port
  1916.     SUport = (SUsec) ? ""+(parseInt(SUport,10) + 0x10000) : SUport;
  1917.       // Process the Specified Service
  1918.       FStorIdx = ServStorIdx+1; // Index to Store for 1st of the Services' Record string
  1919.       for ( var i=0,j=0; i<ServiceTypeCount; i++, FStorIdx+=ServicesRecLength ) {
  1920.           if ( (SAstrg = AC_ServicesStoreArr[FStorIdx]) != "" ) { 
  1921.               warr = SAstrg.split("~"); // parse the parameter string
  1922.             if ( warr[3] == SUtype ) // if match on type
  1923.                 break;
  1924.         }
  1925.         else {
  1926.             j = (j == 0) ? FStorIdx : j; // save index to first null entry   
  1927.         }
  1928.     }
  1929.     if ( i >= ServiceTypeCount ) { // if not found
  1930.         FStorIdx = j; // set index to null entry    
  1931.     }
  1932.     ServEditMode = null; // init
  1933.       if ( SUchk == "checked" ) { // if Service now selected
  1934.           // if found in Store, Replace if necessary
  1935.           if ( (SAstrg = AC_ServicesStoreArr[FStorIdx]) != "" ) { 
  1936.               warr = SAstrg.split("~"); // parse the parameter string
  1937.               // Check if something has changed
  1938.               if ( (warr[4] != SUto && SUto != "") || 
  1939.                     (warr[5] != SUret && SUret != "") || 
  1940.                      (warr[6] != SUport && SUport != "") || 
  1941.                       (warr[12] != SUname && SUname != "") || 
  1942.                        (warr[13] != SUrqst && (SUrqst != "" || SUtype == "HTTP")) || 
  1943.                         (warr[14] != SUresp && (SUresp != "" || SUtype == "HTTP")) ) { 
  1944.                   warr[4] = SUto; warr[5] = SUret; warr[6] = SUport; warr[12] = SUname; // replace values
  1945.                 warr[13] = SUrqst; warr[14] = SUresp; 
  1946.                   SAstrg = warr.join("~"); // recreate string
  1947.                   AC_ServicesStoreArr[FStorIdx] = SAstrg; // update Store
  1948.                 ServEditMode = "Repl"; // set mode
  1949.                   rstat = RpmCC_AC.ServicesReplace(SAstrg);    // update Database
  1950.                   ServiceThreadToggleRequired = true;
  1951.            }
  1952.           }
  1953.           else { // otherwise, initiate Add and let ServiceAddOpComplete update the Store
  1954.           SAstrg = ServEditCID + "~~" + SUtype + "~" + SUto + "~" + SUret + "~" + SUport;
  1955.           SAstrg += "~" + SUname + "~" + SUrqst + "~" + SUresp + "~1";
  1956.           
  1957.             ServAddStrg = ServEditCID + "~~" + SUtype + "~" + SUto + "~" + SUret + "~" + SUport;
  1958.             ServAddStrg += "~~~~~~" + SUname + "~" + SUrqst + "~" + SUresp + "~1";
  1959.             
  1960.               ServEditMode = "Add"; // set mode
  1961.             rstat = RpmCC_AC.ServicesAdd(SAstrg); // Add to Database
  1962.           }    
  1963.     }
  1964.     else { // Service not selected, see if in Store
  1965.         if ( (SAstrg = AC_ServicesStoreArr[FStorIdx]) != "" ) { 
  1966.               warr = SAstrg.split("~"); // parse the parameter string
  1967.               ServEditMode = "Del"; // set mode
  1968.              AC_ServicesStoreArr[FStorIdx] = ""; // set null entry in Store
  1969.               rstat = RpmCC_AC.ServicesDelete(warr[0]);    // Delete from Database
  1970.          }
  1971.     }
  1972.     if ( ServEditMode != null ) { // if Database Op initiated
  1973.         if ( rstat ) { // if unable to initiate request        
  1974.             processEditComplete(); // finish up Edit
  1975.             top.Rstatus.Pstat("Unable to start the Services UPDATE request",true);
  1976.         }
  1977.         else { // waiting for OperationCompleteEvent
  1978.             top.Rstatus.Pstat("One moment while Services UPDATE request completes");
  1979.         }
  1980.     }
  1981.     else { // no DB op pending, go do next Service
  1982.         processServicesOpComplete();
  1983.     }
  1984. }
  1985.  
  1986. /* Process Duplicate Error in Computer Add / Replace Operation */
  1987. function processComputerUpdateErrorDuplicate() {
  1988.     alert("A Server/Device with the name '"+AC_Name.value+"' already exists in the DataBase! Use the Edit function if you want to modify its settings");
  1989.     if ( AddServicesFlag != 0 ) {
  1990.         processAddComputers(); // go set up to Add next computer
  1991.     }
  1992.     else {
  1993.         processResetButton(); // reset
  1994.     }
  1995. }
  1996.  
  1997. /* Process Bad Group Error in Computer Add / Replace Operation */
  1998. function processComputerUpdateErrorBadGroup() {
  1999.     top.Rstatus.Pstat("Invalid Group ID. Cannot complete the UPDATE request",true);
  2000.     processResetButton(); // reset
  2001. }
  2002.  
  2003. /* Process Not Found Error in Computer Replace Operation */
  2004. function processComputerErrorNotFound() {
  2005.     top.Rstatus.Pstat("Server Name not found. Cannot complete the UPDATE/DELETE request",true);
  2006.     processResetButton(); // reset
  2007. }
  2008.  
  2009. /* Process DB Error in Computer Lookup Operation */
  2010. function processComputerOpError() {
  2011.     top.Rstatus.Pstat("An error occurred during requested operation",true);
  2012.     processResetButton(); // reset
  2013. }
  2014.  
  2015. /* Process Error in Computer Add Operation Due to Exceeding Max License Allowed*/
  2016. function processComputerLicenseError() {
  2017.     alert("'"+AC_Name.value+"' not added/changed. Currently at maximum licenses allowed. You have to upgrade your MonitorIT license if you want to monitor additional servers/devices");
  2018.     processResetButton(); // reset
  2019.     top.Rstatus.Pstat("Done! "+TotalComputersAdded+" server(s) added");
  2020. }
  2021.  
  2022.  
  2023. /* Process LOOKUP RECORD Event */
  2024. var Gix3 = 0;
  2025. function processComputerLookupRecord(Cid,Gid,SrvID,Name,Desc,Pswd,OSVer,Addr,Port,AgentVer,DomainName,SNMPInfo) {
  2026.     Desc = (Desc.length == 0) ? "" : Desc;
  2027.     Pswd = (Pswd.length == 0) ? "" : Pswd;
  2028.     OSVer = (OSVer.length == 0) ? "" : OSVer;
  2029.     Addr = (Addr.length == 0) ? "" : Addr;
  2030.     Port = (Port.length == 0) ? "" : Port;
  2031.     SrvID = (SrvID.length == 0) ? "" : SrvID;
  2032.     if ( Gid != CGrpID ) {
  2033.        getGroupName(Gid,AC_GroupSel,AC_GrpStore); // determine GrpSelectIdx;
  2034.         Gix3 = (GroupRecLength*GrpSelectIdx)+3;
  2035.         CGrpID = Gid;
  2036.     }
  2037.     
  2038.     /* if match on a selected Group, add record to store */
  2039.     if ( (allGrpSelected == 1) || (AC_GrpStore.options[Gix3].text == 1) ) {
  2040.         addElementToSelect(AC_NameSel,Name);
  2041.         var i = ComputerRecLength * LupRecCount;
  2042.         AC_StoreArr[i+0] = Name;
  2043.         AC_StoreArr[i+1] = Gid;
  2044.         AC_StoreArr[i+2] = Desc;
  2045.         AC_StoreArr[i+3] = Pswd;
  2046.         AC_StoreArr[i+4] = OSVer;
  2047.         AC_StoreArr[i+5] = Addr;
  2048.         AC_StoreArr[i+6] = Port;
  2049.         AC_StoreArr[i+7] = Cid;
  2050.         AC_StoreArr[i+8] = SrvID;
  2051.         AC_StoreArr[i+9] = AgentVer;
  2052.         AC_StoreArr[i+10] = DomainName; // Domain Name
  2053.         AC_StoreArr[i+11] = SNMPInfo; // Domain Name
  2054.         ++LupRecCount; // bump record received counter
  2055.     }
  2056. }
  2057.  
  2058. // Process Serverices LOOKUP Record Event
  2059. function processServicesRecord(SRVstrg) {
  2060.     var warr = new Array();
  2061.     warr = SRVstrg.split("~");
  2062.     if ( ServiceCompID == null ) { // if first record
  2063.        ServiceCompID = warr[1]; // init with first Computer ID
  2064.     }
  2065.     var i = ServicesRecCount * ServicesRecLength;
  2066.     if ( warr[1] != ServiceCompID ) { // if new Computer ID
  2067.         var wcnt = ServicesRecCount % ServiceTypeCount;
  2068.        while ( wcnt < ServiceTypeCount ) { // round out previous
  2069.             AC_ServicesStoreArr[i++] = ServiceCompID; // Computer ID
  2070.              AC_ServicesStoreArr[i++] = "";
  2071.             ++ServicesRecCount; // bump record counter
  2072.             ++wcnt;
  2073.         } 
  2074.        ServiceCompID = warr[1]; // set new current Computer ID
  2075.     }
  2076.     ++ServicesRecCount; // bump record counter
  2077.     AC_ServicesStoreArr[i++] = warr[1]; // Computer ID
  2078.     AC_ServicesStoreArr[i] = SRVstrg;
  2079. }
  2080.  
  2081. // Process the Add Button Click from the Discovery Services Pop-up
  2082. function processAddServices() {
  2083.     // Disable buttons
  2084.     SetButtonState(bSelC,"1");
  2085.     SetButtonState(bUselC,"1");
  2086.     SetButtonState(bAdd,"1");
  2087.     SetButtonState(DiscoveryResetButton,"1");
  2088.     
  2089.     CMode = "Lookup_DiscoveryAdd"; // set mode of operation
  2090.     allGrpSelected = true; 
  2091.     LupRecCount = 0; // initialize record counter
  2092.     ServiceCompID = null; // init the Service Record Computer ID
  2093.     CurSelectIdx = 0; // reset current select index
  2094.     AC_StoreArr.length = 0;
  2095.     for ( var i=AC_NameSel.length; i>0; i-- ) {
  2096.        AC_NameSel.remove(0);
  2097.     }
  2098.     if ( RpmCC_AC.ComputerLookup("*","*") ) {
  2099.             processAddServicesContinue();
  2100.     }
  2101. }        
  2102. function processAddServicesContinue() {
  2103.     var PrevIPaddr = null; // initialize
  2104.     var SStrg = "";
  2105.     var CkObj = null;
  2106.     CMode = "New"; // restore mode of operation
  2107.     AddServicesArr.length = 0; // reset
  2108.     // Determine Computers and Services to be Added
  2109.     for (var i=0, j=0; i< ELIdx; ++i ) { // Find each one
  2110.         CkObj = LogEventCheckBoxObjectArray[i]; // get line object
  2111.         if ( CkObj.checked && LogEventObjectArray[i].style.display == "" ) { // if checked and visible
  2112.             for (var k=0; k < AC_StoreArr.length; k+=ComputerRecLength) {
  2113.                 if ( CkObj.ipaddr == AC_StoreArr[k+5] ) {
  2114.                     break; // if already in Computer table                        
  2115.                 }
  2116.             }
  2117.             if ( k < AC_StoreArr.length ) {
  2118.                 CkObj.checked = "";
  2119.                continue; // skip it
  2120.             }
  2121.             if ( CkObj.ipaddr != PrevIPaddr ) { // if new one
  2122.                 if ( PrevIPaddr != null ) { // if  not first time
  2123.                     AddServicesArr[j++] = SStrg; // save 
  2124.                 }
  2125.                 PrevIPaddr = CkObj.ipaddr; // set new previous
  2126.                 SStrg = CkObj.ipaddr;
  2127.                 SStrg += "," + CkObj.iname; // add name
  2128.                 SStrg += "," + CkObj.domain;
  2129.                 if ( CkObj.itype != "PING" ) {
  2130.                    SStrg += ",PING"; // insure at least PING by default
  2131.                 }
  2132.             }
  2133.             SStrg += "," + CkObj.itype; // add service type
  2134.         }
  2135.     }
  2136.     if ( SStrg == "" ) {
  2137.        alert("All the Servers/Devices you selected to Add are already in the MonitorIT database!\n -If you want to enable additional IP Services, do a 'Lookup' and 'Edit' of these Servers/Devices");
  2138.         SetButtonState(bSelC,"0");
  2139.         SetButtonState(bUselC,"0");
  2140.         SetButtonState(DiscoveryResetButton,"0");
  2141.         return;
  2142.     }
  2143.  
  2144.     AddServicesArr[j++] = SStrg; // save 
  2145.     ComputerCount.innerText = j;
  2146.     LicCount.style.display = "none";
  2147.     if ( j > (LicenseMax-LicenseCur) ) {
  2148.         ComputerCountMax.innerText = LicenseMax;
  2149.         ComputerCountRem.innerText = (LicenseMax-LicenseCur);
  2150.         ComputerCountRem1.innerText = (LicenseMax-LicenseCur);
  2151.         LicCount.style.display = "";
  2152.     }
  2153.     PopUpConfirm.style.display=""; // enable Add Confirm pop-up
  2154. }
  2155.  
  2156. function processAddConfirmCancelButton() {
  2157.     SetButtonState(bSelC,"0");
  2158.     SetButtonState(bUselC,"0");
  2159.     SetButtonState(bAdd,"0");
  2160.     SetButtonState(DiscoveryResetButton,"0");
  2161.     PopUpConfirm.style.display="none"; // disable Add Confirm pop-up
  2162. }    
  2163.     
  2164. function processAddConfirmOKButton() {
  2165.     PopUpConfirm.style.display="none"; // disable Add Confirm pop-up
  2166.     if ( EditBeforeAdd.checked ) {
  2167.         AddServicesFlag = 1; // Edit first
  2168.     }
  2169.     else {
  2170.         AddServicesFlag = 2; // Add unconditionally
  2171.     }
  2172.     ELogWinMain.style.display="none"; // dismiss log window
  2173.     AC_ServerSel.style.display="";
  2174.     AC_DomainNSel.style.display="";
  2175.     AC_GroupSel.style.display="";
  2176.     AC_MIBSel.style.visibility="visible";
  2177.     AddServicesArrIdx = 0; // set Array Index
  2178.     TotalComputersAdded = 0; // initialize
  2179.     processAddComputers(); // initaite the add
  2180.     ServiceSelect.style.display="";
  2181. }
  2182.  
  2183. //  Carry Out the Computer/Services Add Based on Edit Forst or Unconditional Add
  2184. function processAddComputers() {
  2185.     var warr = new Array();
  2186.     var warr1 = new Array();
  2187.     if ( AddServicesArrIdx < AddServicesArr.length ) {
  2188.         // reset checkboxes
  2189.         resetServiceFields();
  2190.             
  2191.         // set default name to be IP Address
  2192.         warr = AddServicesArr[AddServicesArrIdx++].split(","); // get params
  2193.         top.Rstatus.Pstat("Editing new record "+AddServicesArrIdx+" of "+AddServicesArr.length+"; Press 'Save' button when done editing",true);
  2194.  
  2195.         AC_Name.value = warr[1]; 
  2196.         AC_IPAddr.value = warr[0];
  2197.         AC_Desc.value = "("+warr[1]+") added via Discovery";
  2198.         
  2199.         AC_DomainNSel.selectedIndex = 0;
  2200.         for ( var i=0; i<AC_DomainNSel.length; i++ ) {
  2201.             if ( AC_DomainNSel.options[i].value == warr[2] ) {
  2202.                 AC_DomainNSel.selectedIndex = i;
  2203.                 break;
  2204.             } 
  2205.        }        
  2206.         
  2207.         if ( warr[0] != warr[1] ) { // if name is not IP addr
  2208.             warr1 = warr[1].split(".");
  2209.             AC_Name.value = warr1[0];
  2210.         }
  2211.         // process the selected services
  2212.         for ( var i=3; i<warr.length; i++ ) {
  2213.             switch ( warr[i] ) {
  2214.            case "PING" : 
  2215.               tpingchk = "checked";
  2216.               tpingto = DefaultPingTimeOut;
  2217.               tpingret = "2";
  2218.               break;
  2219.            case "HTTP" : 
  2220.               thttpchk = "checked";
  2221.               thttpport = httpport.value;
  2222.               thttpto = DefaultServiceTimeOut;
  2223.               thttplookfor = "";
  2224.               thttponpage = "";
  2225.               thttpsec = (httpschk.checked) ? "1" : "";
  2226.               break;
  2227.            case "FTP" : 
  2228.               tftpchk = "checked";
  2229.               tftpport = ftpport.value;
  2230.               tftpto = DefaultServiceTimeOut;
  2231.               tftpsec = (ftpschk.checked) ? "1" : "";
  2232.               break;
  2233.            case "SMTP" : 
  2234.               tsmtpchk = "checked";
  2235.               tsmtpport = smtpport.value;
  2236.               tsmtpto = DefaultServiceTimeOut;
  2237.               tsmtpsec = (smtpschk.checked) ? "1" : "";
  2238.                 break;
  2239.            case "POP" : 
  2240.               tpopchk = "checked";
  2241.               tpopport = popport.value;
  2242.               tpopto = DefaultServiceTimeOut;
  2243.               tpopsec = (popschk.checked) ? "1" : "";
  2244.               break;
  2245.            case "DNS" : 
  2246.               tdnschk = "checked";
  2247.               tdnsport = dnsport.value;
  2248.               tdnsto = DefaultServiceTimeOut;
  2249.               tdnsret = "2";
  2250.               tdnsname = dnsname.value
  2251.               break;
  2252.            case "USER" : 
  2253.               tuserchk = "checked";
  2254.               tuserport = userport.value;
  2255.               tuserto = DefaultServiceTimeOut;
  2256.               tuserret = "2";
  2257.               tuserrqst = userrqst.value
  2258.                tuserresp = userresp.value
  2259.                break;
  2260.            case "SQL" : 
  2261.               tsqlchk = "checked";
  2262.               tsqlto = DefaultServiceTimeOut;
  2263.               tsqlparms = warr[1]+",sa,,";
  2264.               AC_Name.value = "SQL Server Check of "+warr[1];
  2265.                break;
  2266.            case "SNMP" : 
  2267.               tsnmpchk = "checked";
  2268.               tsnmpto = DefaultServiceTimeOut;
  2269.               tsnmpret = "2";
  2270.               tsnmpparms = snmprqst.value+",public,1"
  2271.                  break;
  2272.            case "TELNET" : 
  2273.               ttelchk = "checked";
  2274.               ttelport = telport.value;
  2275.               ttelto = DefaultServiceTimeOut;
  2276.                ttelsec = (telschk.checked) ? "1" : "";
  2277.                  break;  
  2278.            case "ORACLE" : 
  2279.               toraclechk = "checked";
  2280.               toracleto = DefaultServiceTimeOut;
  2281.               toracleparms = warr[1]+",sa,,";
  2282.               //AC_Name.value = "SQL Server Check of "+warr[1];
  2283.                break;
  2284.            case "L_NOTES" : 
  2285.               tlnoteschk = "checked";
  2286.               tlnotesport = lnotesport.value;
  2287.               tlnotesto = DefaultServiceTimeOut;
  2288.               tlnotesret = "2";
  2289.               tlnotesrqst = lnotesrqst.value
  2290.                tlnotesresp = lnotesresp.value
  2291.                break;
  2292.                                 
  2293.             }
  2294.         }
  2295.         j=0; // default to PING selected for display
  2296.         if ( tpingchk ) { j = 0; } // find the first service selected
  2297.         else if ( thttpchk ) { j = 1; }
  2298.         else if ( tftpchk ) { j = 2; }
  2299.         else if ( tsmtpchk ) { j = 3; }
  2300.         else if ( tpopchk ) { j = 4; }
  2301.         else if ( tdnschk ) { j = 5; }
  2302.         else if ( tuserchk ) { j = 6; }
  2303.         else if ( tsqlchk ) { j = 7; }
  2304.         else if ( tsnmpchk ) { j = 8; }
  2305.         else if ( ttelchk ) { j = 9; }
  2306.         else if ( toraclechk ) { j = 10; }
  2307.         else if ( tlnoteschk ) { j = 11; }
  2308.     // Hide input fields
  2309.       rqstin.style.visibility="hidden";
  2310.       respin.style.visibility="hidden";
  2311.       sqlsrv.style.visibility="hidden";
  2312.       sqlusr.style.visibility="hidden";
  2313.         ServiceSelect.selectedIndex = j; // set the selected one
  2314.         processServiceSelectPut(); // set up display
  2315.  
  2316.         // if Add without Edit; go do update; otherwiese let user press Update
  2317.         if ( AddServicesFlag == 2 ) { 
  2318.             processUpdateButton();
  2319.         }
  2320.         else { // insure buttons are enabled
  2321.             SetButtonState(CUpdateButton,"0");
  2322.             SetButtonState(CResetButton,"0");
  2323.             SetButtonState(InstallAgentButton,"0");
  2324.             SetButtonState(ManageAgentsButton,"0");
  2325.             SetButtonState(WMButton,"0");
  2326.         }
  2327.     }
  2328.     else { // done; go reset
  2329.         processResetButton();
  2330.         top.Rstatus.Pstat("Done! "+TotalComputersAdded+" computer(s) added");
  2331.         ckQuickStartdone(); // check if QuickStart, and put upmessage box if so
  2332.     }
  2333. }
  2334.  
  2335. // Process the Change of the Current Service Selected from the Drop-Down
  2336. var prevServiceSelectIndex = 0;
  2337. function processServiceSelectChange() {
  2338.     if ( processServiceSelectGet() == false ) // if invalid input
  2339.         return;
  2340.     processServiceSelectPut();
  2341. }
  2342. // Save Fields from Previous Services Selection
  2343. function processServiceSelectGet() {
  2344.     switch ( prevServiceSelectIndex ) {
  2345.    case 0 : 
  2346.       tpingchk = (genchk.checked) ? "checked" : "";
  2347.       if ( chkServiceInput(tpingchk,1,1,0,0,0,0) == false )
  2348.           return false;
  2349.       tpingto = gento.value;
  2350.       tpingret = genret.value;
  2351.       genport.value = "";
  2352.       genname.value = "";
  2353.       genrqst.value = "";
  2354.       genresp.value = "";
  2355.       break;
  2356.    case 1 : 
  2357.       thttpchk = (genchk.checked) ? "checked" : "";
  2358.       if ( chkServiceInput(thttpchk,1,0,1,0,0,0) == false )
  2359.           return false;
  2360.       thttpto = gento.value;
  2361.       thttpport = genport.value;
  2362.       thttpsec = (securechk.checked) ? "1" : "";
  2363.       thttplookfor = genname.value;
  2364.       thttponpage = (genresp.value != "") ? "/"+genresp.value : "";
  2365.       genret.value = "";
  2366.       genrqst.value = "";
  2367.       rqstin.style.visibility="hidden";
  2368.       respin.style.visibility="hidden";
  2369.       break;
  2370.    case 2 : 
  2371.       tftpchk = (genchk.checked) ? "checked" : "";
  2372.       if ( chkServiceInput(tftpchk,1,0,1,0,0,0) == false )
  2373.           return false;
  2374.       tftpto = gento.value;
  2375.       tftpport = genport.value;
  2376.       tftpsec = (securechk.checked) ? "1" : "";
  2377.       genret.value = "";
  2378.       genname.value = "";
  2379.       genrqst.value = "";
  2380.       genresp.value = "";
  2381.       break;
  2382.    case 3 : 
  2383.       tsmtpchk = (genchk.checked) ? "checked" : "";
  2384.       if ( chkServiceInput(tsmtpchk,1,0,1,0,0,0) == false )
  2385.           return false;
  2386.       tsmtpto = gento.value;
  2387.       tsmtpport = genport.value;
  2388.       tsmtpsec = (securechk.checked) ? "1" : "";
  2389.       genret.value = "";
  2390.       genname.value = "";
  2391.       genrqst.value = "";
  2392.       genresp.value = "";
  2393.      break;
  2394.    case 4 : 
  2395.       tpopchk = (genchk.checked) ? "checked" : "";
  2396.       if ( chkServiceInput(tpopchk,1,0,1,0,0,0) == false )
  2397.           return false;
  2398.       tpopto = gento.value;
  2399.       tpopport = genport.value;
  2400.       tpopsec = (securechk.checked) ? "1" : "";
  2401.       genret.value = "";
  2402.       genname.value = "";
  2403.       genrqst.value = "";
  2404.       genresp.value = "";
  2405.       break;
  2406.    case 5 : 
  2407.       tdnschk = (genchk.checked) ? "checked" : "";
  2408.       if ( chkServiceInput(tdnschk,1,1,1,1,0,0) == false )
  2409.           return false;
  2410.       tdnsto = gento.value;
  2411.       tdnsret = genret.value;
  2412.       tdnsport = genport.value;
  2413.       tdnsname = genname.value;
  2414.       genrqst.value = "";
  2415.       genresp.value = "";
  2416.       rqstin.style.visibility="hidden";
  2417.       break;
  2418.    case 6 : 
  2419.       tuserchk = (genchk.checked) ? "checked" : "";
  2420.       if ( chkServiceInput(tuserchk,1,1,1,0,0,0) == false )
  2421.           return false;
  2422.       tuserto = gento.value;
  2423.       tuserret = genret.value;
  2424.       tuserport = genport.value;
  2425.       genname.value = "";
  2426.       tuserrqst = genrqst.value;
  2427.       tuserresp = genresp.value;
  2428.       rqstin.style.visibility="hidden";
  2429.       respin.style.visibility="hidden";
  2430.       break;
  2431.    case 7 : 
  2432.       tsqlchk = (genchk.checked) ? "checked" : "";
  2433.       if ( chkServiceInput(tsqlchk,1,0,0,0,0,0) == false )
  2434.           return false;
  2435.       tsqlto = gento.value;
  2436.       genret.value = "";
  2437.       genport.value = "";
  2438.       genname.value = "";
  2439.       tsqlparms = sqlsrvnme.value+","+sqlusrnme.value+","+genresp.value+","+genrqst.value;
  2440.       genresptext.innerHTML = '<input id="genresp" type="text" maxLength="150" size="25" class="idis" onClick="chkDisabled(this)" onkeypress="chkDisabled(this)" >';
  2441.       genresp.value = "";
  2442.       rqstin.style.visibility="hidden";
  2443.       respin.style.visibility="hidden";
  2444.       sqlsrv.style.visibility="hidden";
  2445.       sqlusr.style.visibility="hidden";
  2446.       break;
  2447.    case 8 : 
  2448.       tsnmpchk = (genchk.checked) ? "checked" : "";
  2449.       if ( chkServiceInput(tsnmpchk,1,1,0,0,1,1) == false )
  2450.           return false;
  2451.       tsnmpto = gento.value;
  2452.       tsnmpret = genret.value;
  2453.       genport.value = "";
  2454.       genname.value = "";
  2455.          var warr = new Array();
  2456.        warr = sqlusrnme.value.split(";");
  2457.        var oid = warr.join("^");
  2458.       tsnmpparms = genrqst.value+","+genresp.value+",1,"+sqlsrvnme.value+","+oid;
  2459.       rqstin.style.visibility="hidden";
  2460.       respin.style.visibility="hidden";
  2461.       sqlsrv.style.visibility="hidden";
  2462.       sqlusr.style.visibility="hidden";
  2463.       break;
  2464.    case 9 : 
  2465.       ttelchk = (genchk.checked) ? "checked" : "";
  2466.       if ( chkServiceInput(ttelchk,1,0,1,0,0,0) == false )
  2467.           return false;
  2468.       ttelto = gento.value;
  2469.       ttelport = genport.value;
  2470.       ttelsec = (securechk.checked) ? "1" : "";
  2471.       genret.value = "";
  2472.       genname.value = "";
  2473.       genrqst.value = "";
  2474.       genresp.value = "";
  2475.       break;
  2476.    case 10 : 
  2477.       toraclechk = (genchk.checked) ? "checked" : "";
  2478.       if ( chkServiceInput(toraclechk,1,0,0,0,0,0) == false )
  2479.           return false;
  2480.       toracleto = gento.value;
  2481.       genret.value = "";
  2482.       genport.value = "";
  2483.       genname.value = "";
  2484.       toracleparms = sqlsrvnme.value+","+sqlusrnme.value+","+genresp.value+","+genrqst.value;
  2485.       genresptext.innerHTML = '<input id="genresp" type="text" maxLength="150" size="25" class="idis" onClick="chkDisabled(this)" onkeypress="chkDisabled(this)" >';
  2486.       genresp.value = "";
  2487.       rqstin.style.visibility="hidden";
  2488.       respin.style.visibility="hidden";
  2489.       sqlsrv.style.visibility="hidden";
  2490.       sqlusr.style.visibility="hidden";
  2491.       break;
  2492.    case 11 : 
  2493.       tlnoteschk = (genchk.checked) ? "checked" : "";
  2494.       if ( chkServiceInput(tlnoteschk,1,1,1,0,0,0) == false )
  2495.           return false;
  2496.       tlnotesto = gento.value;
  2497.       tlnotesret = genret.value;
  2498.       tlnotesport = genport.value;
  2499.       genname.value = "";
  2500.       tlnotesrqst = genrqst.value;
  2501.       tlnotesresp = genresp.value;
  2502.       rqstin.style.visibility="hidden";
  2503.       respin.style.visibility="hidden";
  2504.       break;
  2505.     }
  2506.     return true;
  2507. }
  2508.  
  2509. // Validate Service Parameters Input
  2510. function chkServiceInput(chkflg,toflg,retflg,portflg,nameflg,rqstflg,respflg) {
  2511.     if ( chkflg == "")  // not checked, don't care
  2512.         return true;
  2513.     OKflg = true;
  2514.     if ( toflg == 1 ) { if ( gento.value == "" || gento.value == "0" ) { OKflg = false; gento.focus(); }     }
  2515.     if ( retflg == 1 ) { if ( genret.value == "" || genret.value == "0" ) { OKflg = false; genret.focus(); } }
  2516.     if ( portflg == 1 ) { if ( genport.value == "" ) { OKflg = false; genport.focus(); } }
  2517.     if ( nameflg == 1 ) { if ( genname.value == "" ) { OKflg = false; genname.focus(); } }
  2518.     if ( rqstflg == 1 ) { if ( genrqst.value == "" ) { OKflg = false; genrqst.focus(); } }
  2519.     if ( respflg == 1 ) { if ( genresp.value == "" ) { OKflg = false; genresp.focus(); } }
  2520.     if ( OKflg == false ) { // if NG parameter
  2521.         ServiceSelect.selectedIndex = prevServiceSelectIndex; // reset selected index
  2522.         top.Rstatus.Pstat("Required input parameter missing or invalid 0 value",true);
  2523.         alert("Required input parameter missing or invalid 0 value");
  2524.     }
  2525.     return OKflg;
  2526. }
  2527.  
  2528. // Set Fields for New Current Services Selection
  2529. function processServiceSelectPut() {
  2530.     var warr = new Array();
  2531.     securechk.checked = "";
  2532.     switch ( ServiceSelect.selectedIndex ) {
  2533.    case 0 : 
  2534.       genchk.checked = tpingchk;
  2535.       gento.value = (tpingto=="") ? DefaultPingTimeOut : tpingto;
  2536.       genret.value = (tpingret=="") ? "2" : tpingret;
  2537.       genport.value = "";
  2538.       genname.value = "";
  2539.       genrqst.value = "";
  2540.       genresp.value = "";
  2541.       endisFields(0,1,1,0,0,0,0); // enable disable appropriate fields
  2542.       break;
  2543.    case 1 : 
  2544.       genchk.checked = thttpchk;
  2545.       gento.value = (thttpto=="") ? DefaultServiceTimeOut : thttpto;
  2546.       genret.value = "";
  2547.       genport.value = (thttpport=="") ? "80" : thttpport;
  2548.       genname.value = thttplookfor;
  2549.       genrqst.value = "";
  2550.       securechk.checked = (thttpsec == "1") ? "checked" : "";
  2551.       //parse out the leading "/"
  2552.       genresp.value = thttponpage.substring(1,thttponpage.length);
  2553.       rqstin.style.visibility="visible";
  2554.       genname.style.display="";
  2555.       genrqst.style.display="none";
  2556.       rqsttext.innerText = "Look For: ";
  2557.       rqsttext.title = "Optional, look for this string and verify on checked web page"
  2558.       respin.style.visibility="visible";
  2559.       resptext.innerHTML = "Page Name: ";
  2560.       resptext.title = "Optional, specify an alternate web page to check instead of the default web page"
  2561.         endisFields(1,1,0,1,1,0,1); // enable disable appropriate fields
  2562.       break;
  2563.    case 2 : 
  2564.       genchk.checked = tftpchk;
  2565.       gento.value = (tftpto=="") ? DefaultServiceTimeOut : tftpto;
  2566.       genret.value = "";
  2567.       genport.value = (tftpport=="") ? "21" : tftpport;
  2568.       genname.value = "";
  2569.       genrqst.value = "";
  2570.       genresp.value = "";
  2571.       securechk.checked = (tftpsec == "1") ? "checked" : "";
  2572.       endisFields(1,1,0,1,0,0,0); // enable disable appropriate fields
  2573.      break;
  2574.    case 3 : 
  2575.       genchk.checked = tsmtpchk;
  2576.       gento.value = (tsmtpto=="") ? DefaultServiceTimeOut : tsmtpto;
  2577.       genret.value = "";
  2578.       genport.value = (tsmtpport=="") ? "25" : tsmtpport;
  2579.       genname.value = "";
  2580.       genrqst.value = "";
  2581.       genresp.value = "";
  2582.       securechk.checked = (tsmtpsec == "1") ? "checked" : "";
  2583.       endisFields(1,1,0,1,0,0,0); // enable disable appropriate fields
  2584.       break;
  2585.    case 4 : 
  2586.       genchk.checked = tpopchk;
  2587.       gento.value = (tpopto=="") ? DefaultServiceTimeOut : tpopto;
  2588.       genret.value = "";
  2589.       genport.value = (tpopport=="") ? "110" : tpopport;
  2590.       genname.value = "";
  2591.       genrqst.value = "";
  2592.       genresp.value = "";
  2593.       securechk.checked = (tpopsec == "1") ? "checked" : "";
  2594.       endisFields(1,1,0,1,0,0,0); // enable disable appropriate fields
  2595.       break;
  2596.    case 5 : 
  2597.       genchk.checked = tdnschk;
  2598.       gento.value = (tdnsto=="") ? DefaultServiceTimeOut : tdnsto;
  2599.       genret.value = (tdnsret=="") ? "2" : tdnsret;
  2600.       genport.value = (tdnsport=="") ? "53" : tdnsport;
  2601.       genname.value = tdnsname;
  2602.       genrqst.value = "";
  2603.       genresp.value = "";
  2604.       rqstin.style.visibility="visible";
  2605.       genname.style.display="";
  2606.       genrqst.style.display="none";
  2607.       rqsttext.innerText = "Resolve Name: ";
  2608.       rqsttext.title = "Some domain name is required to use in checking the DNS server";
  2609.       endisFields(0,1,1,1,1,0,0); // enable disable appropriate fields
  2610.       break;
  2611.    case 6 : 
  2612.       genchk.checked = tuserchk;
  2613.       gento.value = (tuserto=="") ? DefaultServiceTimeOut : tuserto;
  2614.       genret.value = (tuserret=="") ? "2" : tuserret;
  2615.       genport.value = (tuserport=="") ? "100" : tuserport;
  2616.       genname.value = "";
  2617.       genrqst.value = tuserrqst;
  2618.       genresp.value = tuserresp;
  2619.       rqstin.style.visibility="visible";
  2620.       respin.style.visibility="visible";
  2621.       genname.style.display="none";
  2622.       genrqst.style.display="";
  2623.       rqsttext.innerHTML = "Request:   ";
  2624.       rqsttext.title = "Required string that is sent to the specified server"
  2625.       resptext.innerHTML = "Response: ";
  2626.       resptext.title = ""
  2627.       endisFields(0,1,1,1,0,1,1); // enable disable appropriate fields
  2628.       break;
  2629.    case 7 : 
  2630.       genchk.checked = tsqlchk;
  2631.       gento.value = (tsqlto=="") ? DefaultServiceTimeOut : tsqlto;
  2632.       genret.value = "";
  2633.       genport.value = "";
  2634.       genname.value = "";
  2635.       genresptext.innerHTML = '<input id="genresp" type="password" maxLength="150" size="25" class="idis" onClick="chkDisabled(this)" onkeypress="chkDisabled(this)" >';
  2636.       warr = tsqlparms.split(",");
  2637.       genrqst.value = warr[3];
  2638.       genresp.value = warr[2];
  2639.       rqstin.style.visibility="visible";
  2640.       respin.style.visibility="visible";
  2641.       genname.style.display="none";
  2642.       genrqst.style.display="";
  2643.       rqsttext.innerHTML = "Database: ";
  2644.       rqsttext.title = ""
  2645.       resptext.innerHTML = "Password: ";
  2646.       resptext.title = ""
  2647.       sqlstext.innerHTML = "Server Name: "
  2648.       sqlutext.innerHTML = "User Name: "
  2649.        sqlsrvnme.value = (warr[0] == "") ? AC_Name.value : warr[0];
  2650.       sqlusrnme.value = warr[1];
  2651.       sqlsrv.style.visibility="visible";
  2652.       sqlusr.style.visibility="visible";
  2653.         if ( CMode == "Edit" || CMode == "New" ) {
  2654.           sqlsrvnme.disabled = sqlsrvnme.className = "";
  2655.           sqlusrnme.disabled = sqlusrnme.className = "";
  2656.          }
  2657.       endisFields(0,1,0,0,0,1,1); // enable disable appropriate fields
  2658.       break;
  2659.    case 8 : 
  2660.       genchk.checked = tsnmpchk;
  2661.       gento.value = (tsnmpto=="") ? DefaultServiceTimeOut : tsnmpto;
  2662.       genret.value = (tsnmpret=="") ? "2" : tsnmpret;
  2663.       genport.value = "";
  2664.       genname.value = "";
  2665.       warr = tsnmpparms.split(",");
  2666.       genrqst.value = warr[0];
  2667.       genresp.value = warr[1];
  2668.       var oid = (warr.length >= 5) ? warr[4] : "";
  2669.          var warrs = new Array();
  2670.        warrs = oid.split("^");
  2671.        oid = warrs.join(";");
  2672.       sqlsrvnme.value = (warr.length >= 4) ? warr[3] : "";
  2673.       sqlusrnme.value = oid;
  2674.       rqstin.style.visibility="visible";
  2675.       respin.style.visibility="hidden";
  2676.       sqlsrv.style.visibility="visible";
  2677.       sqlusr.style.visibility="visible";
  2678.       sqlstext.innerHTML = "Look For: "
  2679.       sqlutext.innerHTML = "OID(s): "
  2680.       genname.style.display="none";
  2681.       genrqst.style.display="";
  2682.       rqsttext.innerHTML = "Read Community:  ";
  2683.       rqsttext.title = ""
  2684.       resptext.innerHTML = ""; //"Write Community: ";
  2685.       resptext.title = ""
  2686.         if ( CMode == "Edit" || CMode == "New" ) {
  2687.           sqlsrvnme.disabled = sqlsrvnme.className = "";
  2688.           sqlusrnme.disabled = sqlusrnme.className = "";
  2689.          }
  2690.       endisFields(0,1,1,0,0,1,1); // enable disable appropriate fields
  2691.       break;
  2692.    case 9 : 
  2693.       genchk.checked = ttelchk;
  2694.       gento.value = (ttelto=="") ? DefaultServiceTimeOut : ttelto;
  2695.       genret.value = "";
  2696.       genport.value = (ttelport=="") ? "23" : ttelport;
  2697.       genname.value = "";
  2698.       genrqst.value = "";
  2699.       genresp.value = "";
  2700.       securechk.checked = (ttelsec == "1") ? "checked" : "";
  2701.       endisFields(1,1,0,1,0,0,0); // enable disable appropriate fields
  2702.       break;
  2703.    case 10 : 
  2704.       genchk.checked = toraclechk;
  2705.       gento.value = (toracleto=="") ? DefaultServiceTimeOut : toracleto;
  2706.       genret.value = "";
  2707.       genport.value = "";
  2708.       genname.value = "";
  2709.       genresptext.innerHTML = '<input id="genresp" type="password" maxLength="150" size="25" class="idis" onClick="chkDisabled(this)" onkeypress="chkDisabled(this)" >';
  2710.       warr = toracleparms.split(",");
  2711.       genrqst.value = warr[3];
  2712.       genresp.value = warr[2];
  2713.       rqstin.style.visibility="visible";
  2714.       respin.style.visibility="visible";
  2715.       genname.style.display="none";
  2716.       genrqst.style.display="";
  2717.       rqsttext.innerHTML = "Database: ";
  2718.       rqsttext.title = ""
  2719.       resptext.innerHTML = "Password: ";
  2720.       resptext.title = ""
  2721.       sqlstext.innerHTML = "Server Name: "
  2722.       sqlutext.innerHTML = "User Name: "
  2723.        sqlsrvnme.value = (warr[0] == "") ? AC_Name.value : warr[0];
  2724.       sqlusrnme.value = warr[1];
  2725.       sqlsrv.style.visibility="visible";
  2726.       sqlusr.style.visibility="visible";
  2727.         if ( CMode == "Edit" || CMode == "New" ) {
  2728.           sqlsrvnme.disabled = sqlsrvnme.className = "";
  2729.           sqlusrnme.disabled = sqlusrnme.className = "";
  2730.          }
  2731.       endisFields(0,1,0,0,0,1,1); // enable disable appropriate fields
  2732.       break;      
  2733.    case 11 : 
  2734.       genchk.checked = tlnoteschk;
  2735.       gento.value = (tlnotesto=="") ? DefaultServiceTimeOut : tlnotesto;
  2736.       genret.value = (tlnotesret=="") ? "2" : tlnotesret;
  2737.       genport.value = (tlnotesport=="") ? "1352" : tlnotesport;
  2738.       genname.value = "";
  2739.       genrqst.value = tlnotesrqst;
  2740.       genresp.value = tlnotesresp;
  2741.       rqstin.style.visibility="visible";
  2742.       respin.style.visibility="visible";
  2743.       genname.style.display="none";
  2744.       genrqst.style.display="";
  2745.       rqsttext.innerHTML = "Request:   ";
  2746.       rqsttext.title = "Required string that is sent to the specified server"
  2747.       resptext.innerHTML = "Response: ";
  2748.       resptext.title = ""
  2749.       endisFields(0,1,1,1,0,1,1); // enable disable appropriate fields
  2750.       break;
  2751.     }
  2752.     prevServiceSelectIndex = ServiceSelect.selectedIndex;
  2753. }
  2754.  
  2755. // Enable/disable appropriate Services Fields
  2756. function endisFields(scF,tF,rF,pF,nF,qF,sF) {
  2757.     if ( CMode != "Edit" && CMode != "New" ) {
  2758.         return; // ignore if not editing mode
  2759.      }
  2760.     if ( scF == 1 ) { securechk.disabled = gento.className = ""; } 
  2761.         else {  securechk.disabled = "disabled"; securechk.className = "idis"; securechk.checked == "" }
  2762.     if ( tF == 1 ) { gento.disabled = gento.className = ""; } 
  2763.         else {  gento.className = "idis"; }
  2764.     if ( rF == 1 ) { genret.disabled = genret.className = ""; } 
  2765.         else { genret.className = "idis"; }
  2766.     if ( pF == 1 ) { genport.disabled = genport.className = ""; } 
  2767.         else { genport.className = "idis"; }
  2768.     if ( nF == 1 ) { genname.disabled = genname.className = ""; } 
  2769.         else { genname.className = "idis"; }
  2770.     if ( qF == 1 ) { genrqst.disabled = genrqst.className = ""; } 
  2771.         else { genrqst.className = "idis"; }
  2772.     if ( sF == 1 ) { genresp.disabled = genresp.className = ""; } 
  2773.         else { genresp.className = "idis"; }
  2774. }
  2775.  
  2776. // Reset all Services Fields
  2777. function resetServiceFields() {
  2778.     tpingchk=""; tpingto="5"; tpingret="";
  2779.     thttpchk=""; thttpport=""; thttpto="5"; thttplookfor=""; thttponpage="";
  2780.     tftpchk=""; tftpport=""; tftpto="5";
  2781.     ttelchk=""; ttelport=""; ttelto="5";
  2782.     tsmtpchk=""; tsmtpport=""; tsmtpto="5";
  2783.     tpopchk=""; tpopport=""; tpopto="5";
  2784.     tdnschk=""; tdnsport=""; tdnsto="5"; tdnsret=""; tdnsname="";
  2785.     tuserchk=""; tuserport=""; tuserto="5"; tuserret=""; tusername="";
  2786.     tuserrqst=""; tuserresp=""; tuserpart="";
  2787.     tsqlchk=""; tsqlto=""; tsqlparms=",sa,,"; 
  2788.     toraclechk=""; toracleto=""; toracleparms=",sa,,"; 
  2789.     tlnoteschk=""; tlnotesport=""; tlnotesto="5"; tlnotesret=""; tlnotesname="";
  2790.     tlnotesrqst=""; tlnotesresp=""; tlnotespart="";
  2791.     tsnmpchk=""; tsnmpto="5"; tsnmpret=""; tsnmpparms="public,public,1"; 
  2792.    genchk.checked=""; gento.value="5"; genret.value=""; securechk.checked="";
  2793.    genport.value = "";    genname.value = ""; genrqst.value = ""; genresp.value = ""; 
  2794. }
  2795.  
  2796. // Reset DB Change Event flag
  2797. function resetDBCEF() {
  2798.     CTid = null;
  2799.     ignoreDBChangeEvent = 0;
  2800. }
  2801.  
  2802. function PopUpContextOpen() {
  2803.     AC_NameSel.style.visibility = "hidden";
  2804.     AC_GroupSel.style.visibility = "hidden";
  2805.     AC_ServerSel.style.visibility = "hidden";
  2806.     AC_DomainNSel.style.visibility = "hidden";
  2807.     ServiceSelect.style.visibility = "hidden";
  2808.     AC_MIBSel.style.visibility="hidden";
  2809. }
  2810. function PopUpContextClose() {
  2811.     AC_NameSel.style.visibility = "visible";
  2812.     AC_GroupSel.style.visibility = "visible";
  2813.     AC_ServerSel.style.visibility = "visible";
  2814.     AC_DomainNSel.style.visibility = "visible";
  2815.     ServiceSelect.style.visibility = "visible";
  2816.     AC_MIBSel.style.visibility="visible";
  2817. }
  2818.  
  2819. // Process Click on the Discovery Show All Checkbox
  2820. var VisibleCount;
  2821. function processShowAll() {
  2822.     var CkObj = null;
  2823.     var DispAll = ShowAllEnabled.checked;
  2824.     ELBgFlg = 0; // init the flag 
  2825.     
  2826.     // Find Log Lines with Good status and not currently in the Database
  2827.     for (var i=0,j=0; i< ELIdx; ++i ) { // Find each one
  2828.         CkObj = LogEventObjectArray[i]; // get line object
  2829.         if ( DispAll || CkObj.istat == "0" ) {
  2830.              if ((ELBgFlg ^= 1) == 0) {
  2831.                 CkObj.style.backgroundColor = "white";    
  2832.             }
  2833.             else {
  2834.                 CkObj.style.backgroundColor = "e8e8e8";
  2835.             }
  2836.            CkObj.style.display = "";
  2837.            ++j;
  2838.         }
  2839.           else {
  2840.             CkObj.style.display = "none";
  2841.         }
  2842.     }
  2843.     VisibleCount = j;
  2844. }
  2845.  
  2846. function processKeyPress() {
  2847.     /* get KeyCode and check if invalid */
  2848.     kc = event.keyCode;
  2849.     stat = 1; // default to OK
  2850.  
  2851.     // Keys:   ~            %           [           ]           #           !
  2852.     if (kc == 126 ||    kc == 37 || kc == 91 ||    kc == 93 || kc == 35 || kc == 33) { // Not acceptable 
  2853.         stat = 0;
  2854.     } // Keys:        *           ?
  2855.     else if ( (kc == 42 || kc == 63) && (event.srcElement.name != "AC_Name" && event.srcElement.name != "AC_Group") ) { //Not acceptable
  2856.         stat = 0;
  2857.     }
  2858.     else if ( (CMode != "" && CMode != "Lookup") && (kc == 42 || kc == 63) ) { // Not accpetable
  2859.         stat = 0;
  2860.     }
  2861.     if (stat == 0) { // if Not Acceptable
  2862.         event.returnValue=false;
  2863.         top.Rstatus.Pstat("Keys ~%*?[]#! are not accepted for this field");    
  2864.         alert("Keys ~%*?[]#! are not accepted for this field");    
  2865.     }
  2866.     else if ( (event.srcElement.name == "AC_Port") && (kc < 48 || kc > 57) ) {
  2867.         event.returnValue=false;
  2868.         top.Rstatus.Pstat("Numeric keys only accepted");
  2869.         alert("Numeric keys only accepted");                    
  2870.     }
  2871.     /*
  2872.     else if ( (event.srcElement.name == "AC_IPAddr") && ((kc < 48 || kc > 57) && (kc != 46)) ) {
  2873.         event.returnValue=false;
  2874.         top.Rstatus.Pstat("Numeric keys or . only accepted");            
  2875.     }
  2876.     */
  2877.     else {
  2878.         top.Rstatus.Pstat(""); // clear status line
  2879.     }
  2880. }    
  2881. function processKeyPressPassword() {
  2882.     /* get KeyCode and check if invalid */
  2883.     kc = event.keyCode;
  2884.     stat = 1; // default to OK
  2885.  
  2886.     // Keys:   ~           
  2887.     if (kc == 126) { // Not acceptable 
  2888.         stat = 0;
  2889.     } // Keys:        *           ?
  2890.     if (stat == 0) { // if Not Acceptable
  2891.         event.returnValue=false;
  2892.         top.Rstatus.Pstat("Tilde Key '~' is not accepted for this field");    
  2893.         alert("Tilde Key '~' is not accepted for this field");    
  2894.     }
  2895.     else {
  2896.         top.Rstatus.Pstat(""); // clear status line
  2897.     }
  2898. }    
  2899.  
  2900. /* Process the Verify Password fields */
  2901. function processVerifyPassword() {
  2902.     if ( AC_Pswd.value != AC_VPswd.value) {
  2903.         AC_VPswd.value = "";
  2904.         top.Rstatus.Pstat("Verify Password Does Not Match Password, please reenter it",true);
  2905.         alert("Verify Password Does Not Match Password, please reenter it");
  2906.         AC_VPswd.focus();        
  2907.     }
  2908.     else {
  2909.         top.Rstatus.Pstat(""); // clear status line
  2910.     }
  2911. }
  2912.  
  2913. /* Process Group OP Complete Event */
  2914. function processGroupOpComplete() {
  2915.     if ( IMode == "Lookup" ) { 
  2916.         if (GrpLupRecCount == 0) { // check if any records found
  2917.             if ( IModeFirstTimeGroup ) { // No records found, try adding default group one time
  2918.                 IModeFirstTimeGroup = false; // reset
  2919.                 IMode = "Add"; // Add Group
  2920.                 rstat = RpmCC_AC.GroupAdd("Auto Register Group","System generated group for auto registered computers");
  2921.                 if ( !rstat ) {
  2922.                     ++ignoreDBChangeEvent; // ignore DB change event
  2923.                     return; // exit and await add complete
  2924.                 }
  2925.             }
  2926.             IMode = "";
  2927.             top.Rstatus.Pstat("No GROUPS found. Go to Configure Groups and define at least one NEW Group",true);
  2928.             AC_GroupSel.className = "idis";
  2929.             AC_Name.className = "idis";
  2930.             if ( AC_GroupSel.style.visibility != "hidden" ) {
  2931.                 AC_GroupSel.focus();
  2932.             }
  2933.         }
  2934.         else {
  2935.             //SetButtonState(CNewButton,"0");
  2936.             top.Rstatus.Pstat("Done");
  2937.             if ( top.QuickStartProcessing ) {
  2938.                 showHelp('Help/QuickStart_Help.htm#Discovery');
  2939.                 processNewButton();    
  2940.                 if ( CMode != "New" ) { // Must be at max license
  2941.                     ckQuickStartdone();
  2942.                 }
  2943.                 else {
  2944.                     processDiscoverButton();
  2945.                     window.focus();    
  2946.                 }
  2947.             }
  2948.             else{
  2949.                 processLookupButton();
  2950.             }
  2951.         }
  2952.     }
  2953.     else if ( IMode == "Add" ) {
  2954.         IMode = "Lookup";
  2955.         if ( RpmCC_AC.GroupLookup("","","") ) { // Group added, try Group lookup
  2956.             top.Rstatus.Pstat("Unable to start the GROUP LOOKUP request",true);
  2957.             IMode = "";    
  2958.         }
  2959.     }
  2960. }
  2961.  
  2962. /* Set initial button state for all buttons */
  2963. function initButtonState() {
  2964.     SetButtonState(CNewButton,"1");
  2965.     SetButtonState(CUpdateButton,"1");
  2966.     SetButtonState(CResetButton,"1");
  2967.     SetButtonState(CEditButton,"1");
  2968.     SetButtonState(CDupButton,"1");
  2969.     SetButtonState(CDeleteButton,"1");
  2970.     SetButtonState(DiscoveryButton,"1");
  2971.     SetButtonState(VerifyButton,"1");
  2972.     SetButtonState(InstallAgentButton,"1");
  2973.     SetButtonState(ManageAgentsButton,"1");
  2974.     SetButtonState(WMButton,"1");
  2975. }
  2976. function SetButtonState(BtObj,BState) {
  2977.     //BtObj.className = (BState == "0") ? "BoxButton" : "BoxButtonD";
  2978.     BtObj.disabled = (BState == "0") ? "" : "disabled";
  2979.     BtObj.bdis = BState;
  2980. }
  2981. function saveButtonState() {
  2982.     sButtonState(CNewButton);
  2983.     sButtonState(CUpdateButton);
  2984.     sButtonState(CResetButton);
  2985.     sButtonState(CEditButton);
  2986.     sButtonState(CDupButton);
  2987.     sButtonState(CDeleteButton);
  2988.     sButtonState(DiscoveryButton);
  2989.     sButtonState(VerifyButton);
  2990.     sButtonState(InstallAgentButton);
  2991.     sButtonState(ManageAgentsButton);
  2992.     sButtonState(WMButton);
  2993. }
  2994. function restoreButtonState() {
  2995.     rButtonState(CNewButton);
  2996.     rButtonState(CUpdateButton);
  2997.     rButtonState(CResetButton);
  2998.     rButtonState(CEditButton);
  2999.     rButtonState(CDupButton);
  3000.     rButtonState(CDeleteButton);
  3001.     rButtonState(DiscoveryButton);
  3002.     rButtonState(VerifyButton);
  3003.     rButtonState(InstallAgentButton);
  3004.     rButtonState(ManageAgentsButton);
  3005.     rButtonState(WMButton);
  3006. }
  3007. function sButtonState(BtObj) {
  3008.     BtObj.sbs = BtObj.bdis;
  3009.     SetButtonState(BtObj,"1")
  3010. }
  3011. function rButtonState(BtObj) {
  3012.     SetButtonState(BtObj,BtObj.sbs)
  3013. }
  3014.  
  3015. /* Process Servers Lookup OP Complete Event */
  3016. function processServersOpComplete() {
  3017.     if ( IMode == "Lookup" ) { // Process Server Lookup
  3018.         if (SrvLupRecCnt == 0) { // check if any records found
  3019.             if ( IModeFirstTimeServer ) { // No records found, try adding default server one time
  3020.                 IModeFirstTimeServer= false; // reset
  3021.                 IMode = "Add"; // Add Server
  3022.                 rstat = RpmCC_AC.ServersAdd("My Local Server","System Generated Default Server","127.0.0.1","82"); // try adding default server
  3023.                 if ( !rstat ) { // if successful    
  3024.                     ++ignoreDBChangeEvent; // ignore DB change event
  3025.                     return; // exit and await add complete
  3026.                 }
  3027.             }
  3028.             IMode = "";    
  3029.             top.Rstatus.Pstat("No SERVERS found. Go to Administer Servers and define at least one NEW Server",true);
  3030.             AC_GroupSel.className = "idis";
  3031.             AC_Name.className = "idis";
  3032.             if ( AC_GroupSel.style.visibility != "hidden" ) {
  3033.                 AC_GroupSel.focus();
  3034.             }
  3035.         }
  3036.         else if ( RpmCC_AC.GroupLookup("","","") ) { // Server found, try Group lookup
  3037.             top.Rstatus.Pstat("Unable to start the GROUP LOOKUP request",true);
  3038.             IMode = "";    
  3039.         }
  3040.     }
  3041.     else if ( IMode == "Add" ) { // Try Servers Lookup Again
  3042.         IMode = "Lookup";
  3043.         if ( RpmCC_AC.AdminServersLookup("*") ) {
  3044.                 IMode = "";
  3045.                 top.Rstatus.Pstat("Unable to start the SERVER LOOKUP request",true);
  3046.         }
  3047.     }
  3048. }
  3049.  
  3050. /* Initialize the Discovery/Verify Status Log Windows */
  3051. function processLogWindow() {
  3052.     /* Format Output to Log Window */
  3053.     ELogWin.innerHTML = ELogWinInit;
  3054.     VisibleCount = 0;
  3055.     LogEventCheckBoxObjectArray.length = LogEventObjectArray.length = 0;
  3056.     FOps = "<table id='ploghdr' border='0' cellpadding='1' cellSpacing='1' width='100%'><tr>";
  3057.     if ( ELChkBoxCount  != -1 ) {
  3058.         FOps += "<td width='4%' align='center' style='background-color:activeborder' class='optextb'>";
  3059.         FOps += "Add" + "</td>";
  3060.     }
  3061.     FOps += "<td width='6%' align='center' style='background-color:activeborder' class='optextb'>";
  3062.     FOps += "Status" + "</td>";
  3063.     FOps += "<td width='23%' align='center' style='background-color:activeborder' class='optextb'>";
  3064.     FOps += "Name" + "</td>";
  3065.     FOps += "<td width='16%' align='center' style='background-color:activeborder' class='optextb'>";
  3066.     FOps += "IP Address" + "</td>";
  3067.     FOps += "<td width='9%' align='center' style='background-color:activeborder' class='optextb'>";
  3068.     FOps += "Type" + "</td>";
  3069.     FOps += "<td width='*' align='center' style='background-color:activeborder' class='optextb'>";
  3070.     FOps += "Reason" + "</td>";
  3071.     FOps += "</tr></table>";
  3072.     ELogWin.insertAdjacentHTML("afterBegin",FOps);
  3073. }
  3074.  
  3075. var LogEventObjectArray = new Array();
  3076. var LogEventCheckBoxObjectArray = new Array();    
  3077. /* Output Discovery/Verify Events to Log Window */
  3078. function outputLogEvent(Lstat,Lipaddr,Ltype,Lreason,Ldname,CDNme) {
  3079.     var warr = new Array();
  3080.     ocolor = (Lstat == 0) ? "g" : "r";
  3081.     Lstatstrg = (Lstat == 0) ? "<img src='images/apply.gif' align='absmiddle' height='16' width='16'>" : "<img src='images/reset.gif' align='absmiddle' height='15' width='15'>";
  3082.     FOps = "<div id='discrow" + ELIdx + "' istat='" + Lstat;
  3083.     if ( ShowAllEnabled.checked == false && Lstat != 0 ) {
  3084.         FOps += "' style='background-color:white;display:none'>";   
  3085.     }
  3086.     else {
  3087.         if ((ELBgFlg ^= 1) == 0) {
  3088.             FOps += "' style='background-color:white;"; 
  3089.         }
  3090.         else {
  3091.             FOps += "' style='background-color:e8e8e8;";
  3092.         }
  3093.         FOps += "'>"; 
  3094.         ++VisibleCount;
  3095.     }
  3096.  
  3097.     FOps += "<table border='0' cellpadding='1' cellSpacing='1' width='100%'><tr>";
  3098.     if ( ELChkBoxCount  != -1 ) {
  3099.         FOps += "<td width='4%' align='center' class='optext'>";
  3100.         FOps += "<input onclick='processCheckClick()' id='disc" + ELIdx + "' ipaddr='";
  3101.         FOps += Lipaddr + "' iname='" + Ldname + "' domain='" + CDNme + "' itype='" + Ltype + "' type='checkbox'>" + "</td>";
  3102.     }
  3103.     FOps += "<td width='6%' class='optext' align='center'>";
  3104.     FOps += Lstatstrg + "</td>";
  3105.     var cdname = ""; // preset tip
  3106.     if ( Ldname != Lipaddr ) {
  3107.         cdname = Ldname;
  3108.         warr = Ldname.split(".");
  3109.         Ldname = warr[0];
  3110.     }
  3111.     FOps += "<td width='23%' style='fontFamily:arial' title='"+cdname+"' class='optext" + ocolor + "'>";
  3112.     FOps += Ldname + "</td>";
  3113.     FOps += "<td width='16%' style='fontFamily:arial' class='optext" + ocolor + "'>";
  3114.     FOps += Lipaddr + "</td>";
  3115.     FOps += "<td width='9%' class='optext" + "'>";
  3116.     FOps += Ltype + "</td>";
  3117.     FOps += "<td width='*' class='optext" + "'>";
  3118.     FOps += Lreason + "</td>";
  3119.     FOps += "</tr></table></div>";
  3120.     ELogText.insertAdjacentHTML("afterBegin",FOps);
  3121.     LogEventObjectArray[ELIdx] = document.all["discrow"+ELIdx];  
  3122.     LogEventCheckBoxObjectArray[ELIdx] = document.all["disc"+ELIdx];  
  3123.     ++ELIdx; // bump index count
  3124. }
  3125.  
  3126. /* Process Response to Discover Request */
  3127. var crip = "", crname = "";
  3128. function processResponse(ReqID,RetCode,Reason,Rname) {
  3129.     for ( var i=0; i<RespAR.length; i+=RespArLth ) {
  3130.         if ( ReqID == RespAR[i] ) { // if match
  3131.             RespCount--; // decrement response count
  3132.             if ( RespAR[i+2] == "SNMP" && RetCode == "0" && Rname != "" ) {
  3133.                 RespAR[i+3] = Rname;
  3134.            }
  3135.            if ( !WinDomain_DIP && DomainLUP.checked == true && RetCode == "0") {
  3136.                if ( crip == RespAR[i+1] && crname != "" ) {
  3137.                    RespAR[i+3] = crname;
  3138.                }
  3139.                else {
  3140.                     crname = RpmMIL.ResolveIPAddrToName(RespAR[i+1]);    
  3141.                     crip = RespAR[i+1];
  3142.                       if ( crname != "" ) {
  3143.                         RespAR[i+3] = crname;
  3144.                     }
  3145.                     else {
  3146.                         crname = crip;
  3147.                     }
  3148.                 }
  3149.             }
  3150.             outputLogEvent(RetCode,RespAR[++i],RespAR[++i],Reason,RespAR[++i],CurrentDiscoveryDomain);
  3151.             break;
  3152.        }
  3153.    }
  3154. }
  3155.  
  3156. // Enable Discovery Pop-up Window
  3157. function processDiscoverButton() {
  3158.     processNewButton();
  3159.     ServiceSelect.style.display="none";
  3160.     AC_ServerSel.style.display="none";
  3161.     AC_DomainNSel.style.display="none";
  3162.     AC_GroupSel.style.display="none";
  3163.     AC_MIBSel.style.visibility="hidden";
  3164.     SetButtonState(CUpdateButton,"1");
  3165.     SetButtonState(CResetButton,"1");
  3166.     SetButtonState(InstallAgentButton,"1");
  3167.     PopUpDiv.style.display="";
  3168.     quad1.focus();
  3169.     SetButtonState(DiscoveryButton,"1");  
  3170. }
  3171.  
  3172. // Process Discovery OK Button
  3173. var RespAR = new Array();
  3174. var SQL_DIP = false;
  3175. var ORACLE_DIP = false;
  3176. var WinDomain_DIP = false;
  3177. var WinDomainUsed = false;
  3178. var WinDomainIdx = -1;
  3179. function processOKButton() {
  3180.     DomainFilter.style.display="none";
  3181.     // Validate input
  3182.     if ( !windomainchk.checked && !ipaddrchk.checked ) {
  3183.         alert("Please select a Discovery Method"); 
  3184.         return;
  3185.     }
  3186.    if ( ipaddrchk.checked ) {
  3187.         if ( quad1.value == "" || quad1.value > 255 ) {
  3188.             alert("Please specify a value less than 255"); 
  3189.             quad1.focus(); return;
  3190.         }
  3191.         if ( quad2.value == "" || quad2.value > 255 ) {
  3192.             alert("Please specify a value less than 255"); 
  3193.             quad2.focus(); return;
  3194.         }
  3195.         if ( quad3.value == "" || quad3.value > 255 ) {
  3196.             alert("Please specify a value less than 255"); 
  3197.             quad3.focus(); return;
  3198.         }
  3199.         if ( quad4from.value == "" || parseInt(quad4from.value,10) > parseInt(quad4to.value,10) ) {
  3200.             alert("Please specify a value less than the 'To' value"); 
  3201.             quad4from.focus(); return;
  3202.         }
  3203.         if ( quad4to.value == "" || quad4to.value > 255 ) {
  3204.             alert("Please specify a value less than 255"); 
  3205.             quad4from.focus(); return;
  3206.         }
  3207.         SrchIdx = parseInt(quad4from.value,10); // initialize indices
  3208.         SrchIdxMax = parseInt(quad4to.value,10);
  3209.         ipaddrbase = quad1.value+"."+quad2.value+"."+quad3.value+".";
  3210.     }
  3211.     else {
  3212.         SrchIdx = 1; // No IP Addr range check
  3213.         SrchIdxMax = 0;    
  3214.     }
  3215.     
  3216.     if ( pingchk.checked == false && httpportchk.checked == false && ftpportchk.checked == false && smtpportchk.checked == false && popportchk.checked == false && dnsportchk.checked == false && userportchk.checked == false && snmpchk.checked == false && telportchk.checked == false) {
  3217.         alert("Please select one or more services by clicking on the associated checkbox(s)!");
  3218.         quad1.focus(); return;
  3219.     }
  3220.  
  3221.     /* Initiate the Discovery */
  3222.     PopUpDiv.style.display="none";
  3223.     SetButtonState(CUpdateButton,"0");
  3224.     SetButtonState(CResetButton,"0");
  3225.     SetButtonState(InstallAgentButton,"0");
  3226.         
  3227.     RespArIx=0;
  3228.     RespAR.length = 0;
  3229.     RespCount = 0; // reset response count
  3230.     ELBgFlg = 0; // flag for alternating background color
  3231.     ELIdx = 0; // output log index
  3232.     ELChkBoxCount = 0; // reset Checkbox count
  3233.     SetButtonState(bAdd,"1");
  3234.     SetButtonState(bSelC,"1");
  3235.     SetButtonState(bUselC,"1");
  3236.     SetButtonState(DiscoveryResetButton,"1");
  3237.     ELogHeader.innerText = "Server Discovery Status";
  3238.     ELogHeaderImg.src="images/discovery.gif" 
  3239.     processLogWindow();
  3240.     bSelC.style.display = ""; 
  3241.    bUselC.style.display = ""; 
  3242.     bAdd.style.display = ""; 
  3243.     ELogWinMain.style.display="";
  3244.     SetButtonState(StopButton,"1");
  3245.     SetButtonState(DiscoveryResetButton,"1");
  3246.     SetButtonState(VerifyButton,"1");
  3247.     SetButtonState(DiscoveryPrintButton,"1");
  3248.     DiscoverWait.style.visibility="visible";
  3249.     
  3250.     // if Windows Domain discovery is checked,initiate it
  3251.     if ( windomainchk.checked ) {
  3252.         WinDomainIdx = -1;
  3253.           WinDomain_DIP = true;
  3254.           WinDomainUsed = true;
  3255.           RespCount=0;
  3256.           CurrentDomainIndex = 0;
  3257.         EnumeratedServersArr.length = 0; // reset array
  3258.         if ( AC_DomainArr.length > 0 ) {
  3259.             // if nothing selected, default to all
  3260.             if ( filter_domainnameSel.selectedIndex < 0 ) {
  3261.                 filter_domainnameSel.selectedIndex = 0;
  3262.                 CurrentDomainIndex = 1; // start with First
  3263.             } 
  3264.             // If All
  3265.             else if ( filter_domainnameSel.selectedIndex == 0 ) {
  3266.                 CurrentDomainIndex = 1; // start with First
  3267.             }
  3268.             // Specific Domain
  3269.             else {
  3270.                 filter_domainname.value = AC_DomainArr[(filter_domainnameSel.selectedIndex * UserRecLength)];
  3271.             }            
  3272.         }
  3273.         var filter = processGetDomainAndFilterSpec();
  3274.         if ( filter == "" ) {
  3275.             WinDomainIdx = 0;    
  3276.         }
  3277.         else {
  3278.             MomText.innerHTML = "";
  3279.             PopUpMoment.style.display = "";
  3280.             top.Rstatus.Pstat("Searching Windows Domain/Workgroup-"+CurrentDomainEnumerated);
  3281.             MomText.innerHTML = "Searching Windows Domain/Workgroup-<br><b>'"+CurrentDomainEnumerated+"'</b><br>Total Found - <b>"+(EnumeratedServersArr.length/EnumeratedServersRecLength)+"</b>";
  3282.              RpmCC_AC.GetEnumeratedServers(filter);
  3283.          }
  3284.     }
  3285.     else if ( DomainLUP.checked != false ) {     
  3286.         WinDomainUsed = false;
  3287.         top.Rstatus.Pstat("Starting Domain Name Lookup");
  3288.     }
  3289.     Tid = setTimeout("processServerDiscovery()",100); // delay and check again
  3290. }
  3291.  
  3292. // Initial Verify Button Processing
  3293. function processVerifyButton() {
  3294. var warr = new Array();
  3295.     if ( processServiceSelectGet() == false ) // if invalid input
  3296.         return;
  3297.     // Check if at least one non-SQL selected
  3298.     if ( tpingchk != false || thttpchk != false || ttelchk != false ||
  3299.             tftpchk != false || tsmtpchk != false || tpopchk != false || 
  3300.             tdnschk != false || tuserchk != false || tsnmpchk != false) {
  3301.         // Make sure IP address is defined
  3302.         if ( AC_IPAddr.value == "" ) {
  3303.             alert("Please define an IP Address!");
  3304.             AC_IPAddr.focus();
  3305.             return;
  3306.         }
  3307.         SrchIdx = SrchIdxMax = 0;
  3308.     }
  3309.     else { // at most, just SQL checked
  3310.         SrchIdx = 1; SrchIdxMax = 0;
  3311.     }
  3312.     if ( toraclechk == false && tsqlchk == false && tpingchk == false && thttpchk == false && ttelchk == false &&
  3313.             tftpchk == false && tsmtpchk == false && tpopchk == false && tlnoteschk == false &&
  3314.             tdnschk == false && tuserchk == false && tsnmpchk == false) {
  3315.         alert("Please select one or more IP Services by clicking on the associated checkbox(s)!");
  3316.         genchk.focus();
  3317.     }
  3318.     else {
  3319.         ServiceSelect.style.display="none";
  3320.         AC_ServerSel.style.display="none";
  3321.         AC_DomainNSel.style.display="none";
  3322.         AC_GroupSel.style.display="none";
  3323.         AC_MIBSel.style.visibility="hidden";
  3324.         ipaddrbase = AC_IPAddr.value;
  3325.         RespArIx = RespAR.length = 0;
  3326.         RespCount = 0; // reset response count
  3327.         ELogText.innerText = ""; // clear
  3328.         ELBgFlg = 0; // flag for alternating background color
  3329.         ELIdx = 0; // output log index
  3330.         ELChkBoxCount = -1; // flag Checkbox count as a Verify
  3331.         ELogHeader.innerText = "Server Verify Status";
  3332.         ELogHeaderImg.src="images/verify.gif" 
  3333.         processLogWindow();
  3334.         ELogWinMain.style.display="";
  3335.         SetButtonState(StopButton,"0");
  3336.        bSelC.style.display = "none"; //SetButtonState(bSelC,"1");
  3337.        bUselC.style.display = "none"; //SetButtonState(bUselC,"1");
  3338.        bAdd.style.display = "none"; //SetButtonState(bAdd,"1");
  3339.         SetButtonState(DiscoveryResetButton,"1");
  3340.         SetButtonState(DiscoveryPrintButton,"1");
  3341.         DiscoverWait.style.visibility="visible";
  3342.         // if SQL verify is checked,initiate it
  3343.         if ( tsqlchk ) {
  3344.             top.Rstatus.Pstat("Verifying SQL Server Database Connect");
  3345.             warr = tsqlparms.split(",");
  3346.            RpmCC_AC.SqlConnectVerify(warr[0],warr[1],warr[2],warr[3],tsqlto);
  3347.            SQL_DIP = true;
  3348.         }
  3349.         // if Oracle verify is checked,initiate it
  3350.         if ( toraclechk ) {
  3351.             top.Rstatus.Pstat("Verifying Oracle Database Connect");
  3352.             warr = toracleparms.split(",");
  3353.            RpmCC_AC.SqlConnectVerify("OracleVerify[]"+ipaddrbase,warr[1],warr[2],warr[3],toracleto);
  3354.            ORACLE_DIP = true;
  3355.         }
  3356.         Tid = setTimeout("processServerDiscovery()",100); // delay and check again
  3357.     }
  3358. }
  3359.  
  3360. // Process the Discovery and Verify Pop-up Accordingly
  3361. var SrchIdx=0, SrchIdxMax=0, RespArIx=0, RespCount=0, RespArLth=4;
  3362. var svlookfor="";
  3363. var CurrentDiscoveryDomain = "";
  3364. function processServerDiscovery() {
  3365.     var warr = new Array();
  3366.     Tid = null; // clear T/O ID
  3367.     if ( StopFlag == true ) {
  3368.         top.Rstatus.Pstat("Checking for IP Services Stopped");
  3369.         finishUp();
  3370.         return;
  3371.     }
  3372.     else if ( WinDomain_DIP ) {
  3373.         if ( WinDomainIdx < 0 || RespCount > 0 ) {
  3374.             Tid = setTimeout("processServerDiscovery()",100); // delay and check again
  3375.             return;
  3376.         }
  3377.         if ( WinDomainIdx >= EnumeratedServersArr.length-1 ) {
  3378.             WinDomain_DIP = false;
  3379.             if ( SrchIdx > SrchIdxMax ) {
  3380.                 top.Rstatus.Pstat("Done Checking for IP Services");
  3381.                 finishUp();
  3382.                 return;    
  3383.             }        
  3384.         }
  3385.     }
  3386.     else if ( SQL_DIP ) {
  3387.         Tid = setTimeout("processServerDiscovery()",100); // delay and check again
  3388.         return;
  3389.     }
  3390.     else if ( ORACLE_DIP ) {
  3391.         Tid = setTimeout("processServerDiscovery()",100); // delay and check again
  3392.         return;
  3393.     }
  3394.     else if ( RespCount > 0 ) { // if waiting on responses from previous
  3395.         Tid = setTimeout("processServerDiscovery()",100); // delay and check again
  3396.         return;
  3397.     }
  3398.     else if ( SrchIdx > SrchIdxMax ) {
  3399.         top.Rstatus.Pstat("Done Checking for IP Services");
  3400.         if ( ELChkBoxCount == -1 ) { // if this is a Verify
  3401.             processServiceSelectPut(); // be sure current display is correct
  3402.         }
  3403.         finishUp();
  3404.         return;
  3405.     }
  3406.     RespCount=0;                
  3407.    SetButtonState(StopButton,"0");
  3408.     crip = crname = ""; // initialize response results
  3409.  
  3410.     var pntmo,htmo,ftmo,ttmo,smtmo,ptmo,dtmo,utmo,stmo,ltmo;
  3411.     if ( ELChkBoxCount == -1 ) { // if this is a Verify
  3412.         snmpc = tsnmpchk;
  3413.         warr = tsnmpparms.split(",");
  3414.         srqst = (warr[0] == "") ? "public" : warr[0];
  3415.         srqst += (warr.length >= 5) ? "~"+warr[4] : ""; // OID
  3416.         srqst += (warr.length >= 4) ? "["+warr[3] : ""; // Look For
  3417.         pingc = tpingchk;
  3418.        httpc = thttpchk;
  3419.        thttpport = (thttpport == "") ? "80" : thttpport;
  3420.        hport = parseInt(thttpport,10);
  3421.        hport = (thttpsec) ? hport+0x10000 : hport;
  3422.        hlookfor = thttplookfor;
  3423.        hpageon = thttponpage;
  3424.         ftpc = tftpchk;
  3425.        tftpport = (tftpport == "") ? "21" : tftpport;
  3426.         fport = parseInt(tftpport,10);
  3427.        fport = (tftpsec) ? fport+0x10000 : fport;
  3428.         telc = ttelchk;
  3429.        tport = (ttelport == "") ? "23" : ttelport;
  3430.         tport = parseInt(ttelport,10);
  3431.        tport = (ttelsec) ? tport+0x10000 : tport;
  3432.         smtpc = tsmtpchk;
  3433.        tsmtpport = (tsmtpport == "") ? "25" : tsmtpport;
  3434.         sport = parseInt(tsmtpport,10);
  3435.        sport = (tsmtpsec) ? sport+0x10000 : sport;
  3436.         popc = tpopchk;
  3437.        tpopport = (tpopport == "") ? "110" : tpopport;
  3438.         pport = parseInt(tpopport,10);
  3439.        pport = (tpopsec) ? pport+0x10000 : pport;
  3440.         dnsc = tdnschk;
  3441.        tdnsport = (tdnsport == "") ? "53" : tdnsport;
  3442.         dnsp = parseInt(tdnsport,10);
  3443.         dnsnme = (tdnsname == "") ? "www.breakoutsoft.com" : tdnsname;
  3444.         userc = tuserchk;
  3445.        tuserport = (tuserport == "") ? "100" : tuserport;
  3446.         userp = parseInt(tuserport,10);
  3447.         urqst = tuserrqst;
  3448.         uresp = tuserresp;        
  3449.         lnotesc = tlnoteschk;
  3450.        tlnotesport = (tlnotesport == "") ? "1352" : tlnotesport;
  3451.         lnotesp = parseInt(tlnotesport,10);
  3452.         lrqst = tlnotesrqst;
  3453.         lresp = tlnotesresp;
  3454.         pntmo=tpingto, htmo=thttpto, ftmot=tftpto, ttmo=ttelto;
  3455.         smtmo=tsmtpto, ptmo=tpopto, dtmo=tdnsto, utmo=tuserto;
  3456.         stmo=tsnmpto, ltmo=tlnotesto;
  3457.     
  3458.         cip = ipaddrbase;
  3459.         cdname = cip;
  3460.         top.Rstatus.Pstat("Checking for IP Services at IP Address: "+cip);
  3461.     }
  3462.     else { // Discovery
  3463.         lnotesc = false;
  3464.         snmpc = snmpchk.checked;
  3465.         srqst = snmprqst.value
  3466.         svlookfor = "";
  3467.        pingc = pingchk.checked;
  3468.        httpc = httpportchk.checked;
  3469.        hport = parseInt(httpport.value,10);
  3470.        hport = (httpschk.checked) ? hport+0x10000 : hport;
  3471.        hlookfor = "";
  3472.        hpageon = "";
  3473.         ftpc = ftpportchk.checked;
  3474.         fport = parseInt(ftpport.value,10);
  3475.        fport = (ftpschk.checked) ? fport+0x10000 : fport;
  3476.         telc = telportchk.checked;
  3477.         tport = parseInt(telport.value,10);
  3478.        tport = (telschk.checked) ? tport+0x10000 : tport;
  3479.         smtpc = smtpportchk.checked;
  3480.         sport = parseInt(smtpport.value,10);
  3481.        sport = (smtpschk.checked) ? sport+0x10000 : sport;
  3482.         popc = popportchk.checked;
  3483.         pport = parseInt(popport.value,10);
  3484.        pport = (popschk.checked) ? pport+0x10000 : pport;
  3485.         dnsc = dnsportchk.checked;
  3486.         dnsp = parseInt(dnsport.value,10);
  3487.         dnsnme = dnsname.value;
  3488.         userc = userportchk.checked;
  3489.         userp = parseInt(userport.value,10);
  3490.         urqst = userrqst.value;
  3491.         uresp = userresp.value;
  3492.         pntmo=pingdto.value, htmo=httpdto.value, ftmo=ftpdto.value, ttmo=teldto.value;
  3493.         smtmo=smtpdto.value, ptmo=popdto.value, dtmo=dnsdto.value, utmo=userdto.value;
  3494.         stmo=snmpdto.value;
  3495.         if ( WinDomain_DIP )    {
  3496.             CurrentDiscoveryDomain = EnumeratedServersArr[WinDomainIdx];
  3497.             cip = EnumeratedServersArr[WinDomainIdx+2];
  3498.             cdname = crname = EnumeratedServersArr[WinDomainIdx+1];
  3499.             if ( cip == "" ) { // no IP Address, try look up again
  3500.                 cip = RpmMIL.ResolveNameToIPAddr(crname);
  3501.                 if ( cip == "" ) { // still no IP Address, skip it
  3502.                     WinDomainIdx += EnumeratedServersRecLength;
  3503.                      Tid = setTimeout("processServerDiscovery()",100); // delay and check next
  3504.                      return;
  3505.                  }
  3506.             }
  3507.             top.Rstatus.Pstat("Checking for IP Services at Server: "+crname);
  3508.         }
  3509.         else {
  3510.             CurrentDiscoveryDomain = "";
  3511.             cip = ipaddrbase+SrchIdx;
  3512.             if ( WinDomainUsed ) {
  3513.                for ( var i=0; i<EnumeratedServersArr.length-1; i+= EnumeratedServersRecLength ) {
  3514.                    if ( cip == EnumeratedServersArr[i+2] ) { // if IP Address already checked
  3515.                        ++SrchIdx; // bump to next
  3516.                          Tid = setTimeout("processServerDiscovery()",100); // delay and check next
  3517.                          return;
  3518.                     }   
  3519.                  }
  3520.             }
  3521.             top.Rstatus.Pstat("Checking for IP Services at IP Address: "+cip);
  3522.             cdname = cip;
  3523.         }
  3524.     }
  3525.  
  3526.     if (  pingc != false ) {
  3527.         RespCount++; 
  3528.         RespAR[RespArIx++] = RpmMIL.Ping(cip,1,parseInt(pntmo,10));
  3529.         RespAR[RespArIx++] = cip;
  3530.         RespAR[RespArIx++] = "PING"; 
  3531.         RespAR[RespArIx++] = cdname;
  3532.     }
  3533.         
  3534.     if ( httpc != false ) {
  3535.         RespCount++;
  3536.         RespAR[RespArIx++] = RpmMIL.HttpPage(cip,hport,parseInt(htmo,10),hpageon,hlookfor);
  3537.         RespAR[RespArIx++] = cip;
  3538.         RespAR[RespArIx++] = "HTTP"; 
  3539.         RespAR[RespArIx++] = cdname;
  3540.     }
  3541.         
  3542.     if ( ftpc != false ) {
  3543.         RespCount++;
  3544.         RespAR[RespArIx++] = RpmMIL.FTP(cip,fport,parseInt(ftmo,10));
  3545.         RespAR[RespArIx++] = cip;
  3546.         RespAR[RespArIx++] = "FTP"; 
  3547.         RespAR[RespArIx++] = cdname;
  3548.     }
  3549.  
  3550.     if ( telc != false ) {
  3551.         RespCount++;
  3552.         RespAR[RespArIx++] = RpmMIL.TELNET(cip,tport,parseInt(ttmo,10));
  3553.         RespAR[RespArIx++] = cip;
  3554.         RespAR[RespArIx++] = "TELNET"; 
  3555.         RespAR[RespArIx++] = cdname;
  3556.     }
  3557.                 
  3558.     if ( smtpc != false ) {
  3559.         RespCount++;
  3560.         RespAR[RespArIx++] = RpmMIL.Smtp(cip,sport,parseInt(smtmo,10));
  3561.         RespAR[RespArIx++] = cip;
  3562.         RespAR[RespArIx++] = "SMTP"; 
  3563.         RespAR[RespArIx++] = cdname;
  3564.     }
  3565.                 
  3566.     if ( popc != false ) {
  3567.         RespCount++;
  3568.         RespAR[RespArIx++] = RpmMIL.Pop(cip,pport,parseInt(ptmo,10));
  3569.         RespAR[RespArIx++] = cip;
  3570.         RespAR[RespArIx++] = "POP"; 
  3571.         RespAR[RespArIx++] = cdname;
  3572.     }
  3573.     
  3574.     if ( dnsc != false ) {
  3575.         RespCount++;
  3576.         RespAR[RespArIx++] = RpmMIL.Dns(cip,dnsp,parseInt(dtmo,10),2,dnsnme);
  3577.         RespAR[RespArIx++] = cip;
  3578.         RespAR[RespArIx++] = "DNS"; 
  3579.         RespAR[RespArIx++] = cdname;
  3580.     }
  3581.     if ( userc != false ) {
  3582.         RespCount++;
  3583.         RespAR[RespArIx++] = RpmMIL.User(cip,userp,parseInt(utmo,10),2,urqst,uresp,"1");
  3584.         RespAR[RespArIx++] = cip;
  3585.         RespAR[RespArIx++] = "USER"; 
  3586.         RespAR[RespArIx++] = cdname;
  3587.     }
  3588.     if ( snmpc != false ) {
  3589.         RespCount++;
  3590.         var SnmpUID = RpmCC_AC.SnmpDiscovery(cip,srqst,"1","0",stmo,"1");
  3591.         RespAR[RespArIx++] = "A"+SnmpUID;
  3592.         RespAR[RespArIx++] = cip;
  3593.         RespAR[RespArIx++] = "SNMP"; 
  3594.         RespAR[RespArIx++] = cdname;
  3595.     }
  3596.     if ( lnotesc != false ) {
  3597.         RespCount++;
  3598.         RespAR[RespArIx++] = RpmMIL.User(cip,lnotesp,parseInt(ltmo,10),2,lrqst,lresp,"1");
  3599.         RespAR[RespArIx++] = cip;
  3600.         RespAR[RespArIx++] = "L_NOTES"; 
  3601.         RespAR[RespArIx++] = cdname;
  3602.     }
  3603.     
  3604.     if ( WinDomain_DIP ) {
  3605.         WinDomainIdx += EnumeratedServersRecLength;
  3606.     }
  3607.     else {
  3608.         ++SrchIdx; // bump to next
  3609.     }
  3610.     Tid = setTimeout("processServerDiscovery()",100); // delay and check next
  3611. }
  3612. function finishUp() {
  3613.     SetButtonState(DiscoveryResetButton,"0");
  3614.     SetButtonState(DiscoveryPrintButton,"0");
  3615.    SetButtonState(StopButton,"1");
  3616.     StopFlag = false;
  3617.     DiscoverWait.style.visibility="hidden";
  3618.       if ( ELChkBoxCount != -1 ) {
  3619.        SetButtonState(bSelC,"0");
  3620.        SetButtonState(bUselC,"0");
  3621.    }
  3622. }
  3623.  
  3624. // Pop-up Button Processing, Cancel, Stop, Reset, Default
  3625. function processCancelButton() {
  3626.     DomainFilter.style.display="none";
  3627.     PopUpDiv.style.display="none";
  3628.     ServiceSelect.style.display="";
  3629.     AC_ServerSel.style.display="";
  3630.     AC_DomainNSel.style.display="";
  3631.     AC_GroupSel.style.display="";
  3632.     AC_MIBSel.style.visibility="visible";
  3633.     SetButtonState(CUpdateButton,"0");
  3634.     SetButtonState(CResetButton,"0");
  3635.     SetButtonState(InstallAgentButton,"0");
  3636.     AddServicesFlag = 0; // reset 
  3637.     SetButtonState(DiscoveryButton,"0");  
  3638. }
  3639. function processStopButton() {
  3640.     finishUp();
  3641.     StopFlag = true;
  3642. }
  3643. function processDiscoveryResetButton() {
  3644.     top.Rstatus.Pstat("");
  3645.     ELogWinMain.style.display="none";
  3646.     //AC_ServerSel.style.display="";
  3647.     AC_DomainNSel.style.display="";
  3648.     AC_GroupSel.style.display="";
  3649.     AC_MIBSel.style.visibility="visible";
  3650.     ServiceSelect.style.display="";
  3651.     processServiceSelectPut();
  3652.     if (CMode == "New") {
  3653.         SetButtonState(DiscoveryButton,"0");  
  3654.         SetButtonState(VerifyButton,"0");
  3655.     }
  3656. }
  3657. function processDefaultButton() {
  3658.     httpport.value = (httpschk.checked) ? "443" : "80";
  3659.     ftpport.value = (ftpschk.checked) ? "990" : "21";
  3660.     smtpport.value = (smtpschk.checked) ? "465" : "25";
  3661.     popport.value = (popschk.checked) ? "995" : "110";
  3662.     dnsport.value = "53";
  3663.     userport.value = "100";
  3664.     telport.value = (telschk.checked) ? "992" : "23";
  3665.     
  3666. }
  3667.  
  3668. /* Process Click on an Discovery Entry or Select All/Unselect All Button*/
  3669. function processDiscoverySelect() {
  3670.     if ( event.srcElement.id == "bSelC" ) { // Check all Visible
  3671.         for (var i=0,j=0; j< VisibleCount; ++i ) { // Find each one
  3672.             if ( LogEventObjectArray[i].style.display == "" ) { // Check if visible
  3673.                   LogEventCheckBoxObjectArray[i].checked = "checked";
  3674.                   ++j; 
  3675.               }
  3676.           }
  3677.           if ( j > 0 ) {
  3678.            SetButtonState(bAdd,"0");
  3679.        }
  3680.         ELChkBoxCount = j; // count of checked         
  3681.     }
  3682.     else { // Uncheck all Visible
  3683.          for (var i=0,j=0; j< VisibleCount; ++i ) { // Find each one
  3684.             if ( LogEventObjectArray[i].style.display == "" ) { // Check if visible
  3685.                   LogEventCheckBoxObjectArray[i].checked = "";
  3686.                 ++j;
  3687.             }
  3688.         }
  3689.        SetButtonState(bAdd,"1");
  3690.         ELChkBoxCount = 0;             
  3691.     }
  3692. }
  3693. function processCheckClick() {
  3694.     if ( document.all[event.srcElement.id].checked == "" ) {
  3695.         --ELChkBoxCount;
  3696.     }
  3697.     else {
  3698.         ++ELChkBoxCount;
  3699.     }
  3700.     if ( ELChkBoxCount != 0 ) {
  3701.            SetButtonState(bAdd,"0");
  3702.     }
  3703.     else {
  3704.            SetButtonState(bAdd,"1");
  3705.     }
  3706. }
  3707.  
  3708. // Print Discovery
  3709. var DiscStatWindow = null;
  3710. function processPrintDiscovery() {
  3711.     if ( !top.banner.IE55orBetter ) {
  3712.         alert("Print requires IE 5.5/SP1 or greater. Download current, free IE update from Microsoft's web site");
  3713.         return;
  3714.     }
  3715.     FakeBut.click();    // simulate event to call "savePageCoord(...)"
  3716.     var wprop = "height="+top.banner.bCh+",width="+top.banner.bCw
  3717.     wprop += ",top="+(top.banner.bY-28)+",left="+(top.banner.bX-4)+",scrollbars";
  3718.     var rName = ""+Math.random(); // use Random number to get unique Window name
  3719.     rName = rName.substring(2,rName.length);
  3720.     DiscStatWindow = window.open("",rName,wprop);
  3721.     if ( DiscStatWindow == null ) {
  3722.         return;   
  3723.     }
  3724.     var dh = "<html><head><title>MonitorIT - Server Discovery Status Report</title>";
  3725.     dh += "<link rel='stylesheet' type='text/css' href='css/rpmstyle.css'></head><body";
  3726.     dh += " title='Exit to Close Window when Printing is complete'>"; 
  3727.     dh += ELogWin.innerHTML;
  3728.     dh += "<script LANGUAGE='JavaScript'>ploghdr.border='1'; window.focus();";
  3729.     dh += "< /script>< /body>< /html>";
  3730.  
  3731.     DiscStatWindow.document.open();
  3732.     DiscStatWindow.document.write(dh);
  3733.     DiscStatWindow.document.close();
  3734.     DiscStatWindow.print();
  3735. }
  3736.  
  3737. function procHttpschk() {
  3738.     if ( httpschk.checked ) 
  3739.         httpport.value = "443";
  3740. }
  3741. function procFtpschk() {
  3742.     if ( ftpschk.checked ) 
  3743.         ftpport.value = "990";
  3744. }
  3745. function procSmtpschk() {
  3746.     if ( smtpschk.checked ) 
  3747.         smtpport.value = "465";
  3748. }
  3749. function procPopschk() {
  3750.     if ( popschk.checked ) 
  3751.         popport.value = "995";
  3752. }
  3753. function procTelschk() {
  3754.     if ( telschk.checked ) 
  3755.         telport.value = "992";
  3756. }
  3757. function procSecureChk() {
  3758.     if ( securechk.checked ) {
  3759.         var gpv = "0";
  3760.         var ssi = ServiceSelect.selectedIndex;
  3761.         if ( ssi == 1 ) { gpv = "443"; }
  3762.         else if ( ssi == 2 ) { gpv = "990"; }
  3763.         else if ( ssi == 3 ) { gpv = "465"; }
  3764.         else if ( ssi == 4 ) { gpv = "995"; }
  3765.         else if ( ssi == 9 ) { gpv = "992"; }
  3766.         genport.value = gpv;
  3767.     }
  3768. }
  3769.  
  3770. // Enable IP Address Lookup Window Pop-up Window
  3771. function processInstallAgentButton() {
  3772.     if ( AC_Name.value == "" ) {
  3773.         alert("Please specify the server/workstation machine name");
  3774.         AC_Name.focus();
  3775.         return;
  3776.     }
  3777.     SetButtonState(OKButtonAIP,"0"); // enable
  3778.     SetButtonState(CancelButtonAIP,"0");
  3779.     saveButtonState();
  3780.     AC_DomainNSel.style.visibility = "hidden";
  3781.     PopUpAI.style.display="";
  3782.     DefaultPathCheckbox.style.display = "none";
  3783.     AIPath.value = CreateAIPath(AC_Name.value);
  3784. }
  3785. function processAIPCancelButton() {
  3786.     PopUpAI.style.display="none"; // disable pop-up
  3787.     if ( GlobalAIP ) {
  3788.         GlobalAIP = false;
  3789.     }
  3790.     else {
  3791.         AC_DomainNSel.style.visibility = "";
  3792.         restoreButtonState();
  3793.         if ( AC_NameSel.style.visibility != "hidden" && AC_NameSel.style.display == "" ) {
  3794.             AC_NameSel.focus();
  3795.         }
  3796.     }
  3797. }    
  3798.  
  3799. function processCheckBoxClick(th) {
  3800.     switch ( th.id ) {
  3801.    case "AC_SNMPEnabled" : 
  3802.         if ( th.checked ) {
  3803.             if ( GotMIBData ) {
  3804.                 SetButtonState(MIBObjectButton,"0");
  3805.             }
  3806.             AC_MIBSel.className = ""; 
  3807.             AC_ReadComm.className = ""; 
  3808.             AC_SNMPPort.className = ""; 
  3809.             AC_Collection.className = ""; 
  3810.         }
  3811.         else {
  3812.             if ( CMode == "New" || confirm("Disabling SNMP Monitoring for this server/device will remove its\nassociated Objects/Counters and monitored Values from the database\nwhen you press the 'Save' button.\n\nAre you sure you want to disable SNMP Monitoring for this server/device?") ) {    
  3813.                 SetButtonState(MIBObjectButton,"1");
  3814.                 AC_MIBSel.className = "idis"; 
  3815.                 AC_ReadComm.className = "idis"; 
  3816.                 AC_SNMPPort.className = "idis"; 
  3817.                 AC_Collection.className = "idis"; 
  3818.             }
  3819.             else {
  3820.                 th.checked = "checked";
  3821.             }            
  3822.         }
  3823.       break;
  3824.     }
  3825. }
  3826.     
  3827. function processAIPOKButton() {
  3828.     if ( GlobalAIP ) {
  3829.         processGlobalAgentPath();
  3830.         return; // Done if called from Manage Agents
  3831.     }
  3832.     SetButtonState(OKButtonAIP,"1"); // disable
  3833.     SetButtonState(CancelButtonAIP,"1");
  3834.     if ( AC_DomainN.value == "" ) {
  3835.          AC_DomainN.value = AC_DomainNSel.options[AC_DomainNSel.selectedIndex].value;
  3836.      }
  3837.  
  3838.     var AI_arg = AIPath.value+"~"+AC_IPAddr.value+"~";
  3839.     if ( AC_DomainArr.length == 0 ) {
  3840.         AI_arg += logon_username.value+"~"+logon_password.value+"~"+logon_domainname.value+"~";
  3841.     }
  3842.     else {
  3843.         // Look for match on server/workstation name and a Domain name which is also a 'stand-alone'
  3844.         for ( var i=0; i<AC_DomainArr.length; i+=UserRecLength ) {
  3845.             if ( AC_DomainArr[i+5] == "3" && AC_DomainArr[i].toLowerCase() == AC_Name.value.toLowerCase() ) {
  3846.                 // Match found on a stand-alone; use those Domain entry credentials
  3847.                 AI_arg += AC_DomainArr[i+4]+"~" +AC_DomainArr[i+3]+"~"+AC_DomainArr[i]+"~";
  3848.                 break;
  3849.             } 
  3850.         }        
  3851.         if ( i >= AC_DomainArr.length ) {            
  3852.             // no match on stand-alone; find match on Domain member
  3853.             var  daidx=0;
  3854.             for ( var i=0; i<AC_DomainArr.length; i+=UserRecLength ) {
  3855.                if ( AC_DomainN.value == AC_DomainArr[i] ) {
  3856.                    daidx = i;
  3857.                    break;
  3858.                }
  3859.             }
  3860.             // Check if any credentials provided for matched Doamin
  3861.             if ( AC_DomainArr[daidx+4].length > 0 ) { 
  3862.                 AI_arg += AC_DomainArr[daidx+4]+"~"+AC_DomainArr[daidx+3]+"~";
  3863.             }
  3864.             else { // otherwise use <All> credentials if any for the matched Domain
  3865.                 AI_arg += AC_DomainArr[4]+"~"+AC_DomainArr[3]+"~";
  3866.             }
  3867.             AI_arg += ( (daidx == 0) ? "" : AC_DomainArr[daidx] )+"~";
  3868.         }
  3869.     }
  3870.     while ( AI_arg.length < 512 ) {
  3871.         AI_arg += AI_arg;
  3872.    }
  3873.     if ( RpmCC_AC.AgentInstall( AI_arg ) ) {
  3874.         alert("Unable to start the Agent Install/Update process");
  3875.         top.Rstatus.Pstat("Unable to start the Agent Install/Update process",true);
  3876.     }    
  3877.     else { // waiting for OperationCompleteEvent
  3878.           SetCursor("wait");
  3879.           top.banner.processStartComm();
  3880.         top.Rstatus.Pstat("One moment while Agent Install/Update proceeds",true);
  3881.     }
  3882.     AC_DomainNSel.style.visibility = "";
  3883.     PopUpAI.style.display="none"; // disable pop-up
  3884. }
  3885.  
  3886. // Create new Window and load specified Page
  3887. function processAdminGroupButton() {
  3888.     processPopUpSelect(11,false);
  3889.     return;
  3890. }
  3891. function processConfigAlertButton() {
  3892.     processPopUpSelect(1,false);
  3893.     return;
  3894. }
  3895.  
  3896. var viewToggle = 0;
  3897. function processMonServerButton() {
  3898.     if ( viewToggle == 0 ) {
  3899.         viewToggle = 1;
  3900.         MonServerRow0.style.visibility = "visible";
  3901.         MonServerRow1.style.visibility = "visible";
  3902.         AC_ServerSel.style.display = (CMode == "New" || CMode == "Edit") ? "" : "none";
  3903.     }
  3904.     else {
  3905.         viewToggle = 0;   
  3906.         MonServerRow0.style.visibility = "hidden";
  3907.         MonServerRow1.style.visibility = "hidden";
  3908.         AC_ServerSel.style.display = "none";
  3909.     } 
  3910. }
  3911.  
  3912. // Print Log
  3913. var DiscStatWindow = null;
  3914. function processAgentPrintStatus() {
  3915.     if ( !top.banner.IE55orBetter ) {
  3916.         alert("Print requires IE 5.5/SP1 or greater. Download current, free IE update from Microsoft's web site");
  3917.         return;
  3918.     }
  3919.     FakeBut.click();    // simulate event to call "savePageCoord(...)"
  3920.     var wprop = "height="+top.banner.bCh+",width="+top.banner.bCw
  3921.     wprop += ",top="+(top.banner.bY-28)+",left="+(top.banner.bX-4)+",scrollbars";
  3922.     var rName = ""+Math.random(); // use Random number to get unique Window name
  3923.     rName = rName.substring(2,rName.length);
  3924.     DiscStatWindow = window.open("",rName,wprop);
  3925.     if ( DiscStatWindow == null ) {
  3926.         return;   
  3927.     }
  3928.     var dh = "<html><head><title>MonitorIT - Manage Agent Status Report</title>";
  3929.     dh += "<link rel='stylesheet' type='text/css' href='css/rpmstyle.css'></head><body";
  3930.     dh += " title='Exit to Close Window when Printing is complete'>"; 
  3931.     var warr = new Array();
  3932.     warr = AgentWin.innerHTML.split("onclick");
  3933.     dh += warr.join("");
  3934.     dh += ' </body></html>';    
  3935.     
  3936.     DiscStatWindow.document.open();
  3937.     DiscStatWindow.document.write(dh)
  3938.     DiscStatWindow.document.close();
  3939.     DiscStatWindow.print();
  3940. }
  3941.  
  3942. var savDN="", savPW="", savUN="";
  3943. function processLogonInfo() {
  3944.     if ( AC_DomainArr.length == 0 ) {
  3945.         logon_domainnameSel.style.display = "none";
  3946.         logon_domainname.style.display = "";   
  3947.         LogonApplyButton.style.display = "none";
  3948.         SpecifyText.style.display = "";
  3949.         SelectText.style.display = "none";
  3950.         savDN = logon_domainname.value;
  3951.         savPW = logon_password.value;
  3952.         savUN = logon_username.value;
  3953.     }
  3954.     else {
  3955.         logon_domainnameSel.style.display = "";
  3956.         logon_domainname.style.display = "none";
  3957.         LogonApplyButton.style.display = "";
  3958.         SpecifyText.style.display = "none";
  3959.         SelectText.style.display = "";
  3960.  
  3961.         lth = logon_domainnameSel.length;
  3962.         for (i=0; i < lth; ++i)
  3963.             logon_domainnameSel.remove(0);
  3964.         for ( var i=0; i<AC_DomainArr.length; i+=UserRecLength ) {
  3965.             addElementToSelect(logon_domainnameSel,AC_DomainArr[i]+DtypTxt[parseInt(AC_DomainArr[i+5],10)]);
  3966.         }        
  3967.         logon_username.value = AC_DomainArr[4];
  3968.         logon_password.value = AC_DomainArr[3];
  3969.     }
  3970.     AC_DomainNSel.style.visibility = "hidden";
  3971.     AC_GroupSel.style.visibility = "hidden";
  3972.     LogonInfo.style.display = "";
  3973.     logon_username.focus();
  3974. }
  3975. function processLogonOKButton() {
  3976.     processLogonApplyButton();
  3977.     AC_DomainNSel.style.visibility = "";
  3978.     AC_GroupSel.style.visibility = "";
  3979.     LogonInfo.style.display = "none";
  3980. }
  3981. function processLogonApplyButton() {
  3982.     var i = logon_domainnameSel.selectedIndex * UserRecLength;
  3983.     AC_DomainArr[i+3] = logon_password.value;
  3984.     AC_DomainArr[i+4] = logon_username.value;    
  3985. }
  3986. function processDomainNameChange() {
  3987.     var i = logon_domainnameSel.selectedIndex * UserRecLength;
  3988.     logon_password.value = AC_DomainArr[i+3];
  3989.     logon_username.value = AC_DomainArr[i+4];    
  3990. }
  3991.  
  3992. function processLogonCancelButton() {
  3993.     LogonInfo.style.display = "none";
  3994.     AC_DomainNSel.style.visibility = "";
  3995.     AC_GroupSel.style.visibility = "";
  3996.     logon_username.value = savUN;
  3997.     logon_password.value = savPW;
  3998.     logon_domainname.value = savDN;
  3999. }
  4000.  
  4001. // For Test Purposes
  4002. function processTestAddComputers() {
  4003.     for ( var i=0; i<500; i++ ) {
  4004.         AddServicesArr[i] = "192.168.1.117,Test"+i+200+",PING";
  4005.     }
  4006.     CMode = "New";
  4007.     AddServicesFlag = 2; // Add unconditionally
  4008.     AddServicesArrIdx = 0;
  4009.     TotalComputersAdded = 0;
  4010.     processAddComputers();
  4011. }
  4012.  
  4013. function CreateAIPath(cname) {
  4014.      return "\\\\" + cname + "\\C$\\Program Files\\MonitorIT";
  4015. }
  4016.